[Hibernate-JIRA] Created: (BVAL-36) Validation of method parameters and returned values
by Emmanuel Bernard (JIRA)
Validation of method parameters and returned values
---------------------------------------------------
Key: BVAL-36
URL: http://opensource.atlassian.com/projects/hibernate/browse/BVAL-36
Project: Bean Validation
Issue Type: New Feature
Components: spec-general
Reporter: Emmanuel Bernard
Assignee: Emmanuel Bernard
The goal is to expose the necessary APIs to validate method parameters and returned type. This API can typically be used by an interceptor framework.
Validator {
List<IC> validateParameters(Method, Object[] parameterValues);
List<IC> validateParameter(Method, Object parameterValue, int parameterIndex);
List<IC> validateReturnedValue(Method, Object returnedValue);
List<IC> validateParameters(Constructor, Object[] parameterValues);
List<IC> validateParameter(Constructor, Object parameterValue, int parameterIndex);
}
Metadata
Validator {
BeanDescriptor getConstraintsForBean()
PropertyDescriptor getConstraintsForProperty(String propertyName);
MethodDescriptor getConstraintsForMethod(Method);
MethodDescriptor getConstraintsForConstructor(Constructor);
String[] getValidatedProperties();
Method[] getValidatedMethods();
Constructor[] getValidatedConstructors();
}
ElementDescriptor {
ElementType getElementType();
Class getType();
List<ConstraintDescriptor> getConstraintDescriptors();
}
PropertyDescriptor extends ElementDescriptor {
boolean isCascaded();
String getPropertyPath();
}
ParameterDescriptor extends ElementDescriptor {
boolean isCascaded();
int getIndex();
}
BeanDescriptor extends ElementDescriptor {
}
MethodDescriptor extends ElementDescriptor {
List<ParameterDescriptor> getParameterDescriptors(); //index aligned
boolean isCascaded();
}
ConstructorDescriptor extends ElementDescriptor {
List<ParameterDescriptor> getParameterDescriptors(); //index aligned
}
How to read parameter annotations
Class<?> parameterTypes = method.getParameterTypes()
Annotation[][] parameterAnnotations = method.getParameterAnnotations()
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years, 10 months
[Hibernate-JIRA] Commented: (HHH-1598) SchemaValidator fails when using boolean with HSQL
by Clay Atkins (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1598?page=c... ]
Clay Atkins commented on HHH-1598:
----------------------------------
This shouldn't be left unresolved. If you change the DML to BIT type validation still fails.
> SchemaValidator fails when using boolean with HSQL
> --------------------------------------------------
>
> Key: HHH-1598
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1598
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.1.3
> Environment: HSQL 1.8.0.2
> Reporter: objective
> Assignee: Diego Plentz
> Priority: Minor
> Attachments: Cat.zip
>
>
> chemaValidator fails when using boolean with HSQL
> Table.validateColumns() fails with table with column type="boolean". The table is created automatically using hbm2ddl.
> HSQL 1.8.0.2
> Exception in thread "main" org.hibernate.HibernateException: Wrong column type: abc, expected: bit
> at org.hibernate.mapping.Table.validateColumns(Table.java:219)
> at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:965)
> at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:116)
> at HsqlHibernateBit.main(HsqlHibernateBit.java:10)
> 20:26:31 [ main] INFO [Environment ] - Hibernate 3.1.3
> 20:26:31 [ main] INFO [Environment ] - hibernate.properties not found
> 20:26:31 [ main] INFO [Environment ] - using CGLIB reflection optimizer
> 20:26:31 [ main] INFO [Environment ] - using JDK 1.4 java.sql.Timestamp handling
> 20:26:32 [ main] INFO [Configuration ] - configuring from resource: hibernate-HSQL.cfg.xml
> 20:26:32 [ main] INFO [Configuration ] - Configuration resource: hibernate-HSQL.cfg.xml
> 20:26:32 [ main] DEBUG [DTDEntityResolver ] - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd]
> 20:26:32 [ main] DEBUG [DTDEntityResolver ] - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
> 20:26:32 [ main] DEBUG [DTDEntityResolver ] - located [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd] in classpath
> 20:26:32 [ main] DEBUG [Configuration ] - hibernate.connection.driver_class=org.hsqldb.jdbcDriver
> 20:26:32 [ main] DEBUG [Configuration ] - hibernate.connection.url=jdbc:hsqldb:mem:cat
> 20:26:32 [ main] DEBUG [Configuration ] - hibernate.connection.username=sa
> 20:26:32 [ main] DEBUG [Configuration ] - hibernate.connection.password=
> 20:26:32 [ main] DEBUG [Configuration ] - hibernate.connection.pool_size=1
> 20:26:32 [ main] DEBUG [Configuration ] - hibernate.dialect=org.hibernate.dialect.HSQLDialect
> 20:26:32 [ main] DEBUG [Configuration ] - hibernate.show_sql=false
> 20:26:32 [ main] DEBUG [Configuration ] - hibernate.hbm2ddl.auto=update
> 20:26:32 [ main] INFO [Configuration ] - Configured SessionFactory: null
> 20:26:32 [ main] INFO [Configuration ] - Reading mappings from resource: Cat.hbm.xml
> 20:26:32 [ main] DEBUG [DTDEntityResolver ] - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd]
> 20:26:32 [ main] DEBUG [DTDEntityResolver ] - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
> 20:26:32 [ main] DEBUG [DTDEntityResolver ] - located [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] in classpath
> 20:26:32 [ main] INFO [HbmBinder ] - Mapping class: Cat -> Cat
> 20:26:32 [ main] DEBUG [HbmBinder ] - Mapped property: abc -> abc
> 20:26:32 [ main] DEBUG [Configuration ] - Preparing to build session factory with filters : {}
> 20:26:32 [ main] DEBUG [Configuration ] - processing extends queue
> 20:26:32 [ main] DEBUG [Configuration ] - processing collection mappings
> 20:26:32 [ main] DEBUG [Configuration ] - processing native query and ResultSetMapping mappings
> 20:26:32 [ main] DEBUG [Configuration ] - processing association property references
> 20:26:32 [ main] DEBUG [Configuration ] - processing foreign key constraints
> 20:26:32 [ main] INFO [riverManagerConnectionProvider] - Using Hibernate built-in connection pool (not for production use!)
> 20:26:32 [ main] INFO [riverManagerConnectionProvider] - Hibernate connection pool size: 1
> 20:26:32 [ main] INFO [riverManagerConnectionProvider] - autocommit mode: false
> 20:26:32 [ main] INFO [riverManagerConnectionProvider] - using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:mem:cat
> 20:26:32 [ main] INFO [riverManagerConnectionProvider] - connection properties: {user=sa, password=}
> 20:26:32 [ main] DEBUG [riverManagerConnectionProvider] - total checked-out connections: 0
> 20:26:32 [ main] DEBUG [riverManagerConnectionProvider] - opening new JDBC connection
> 20:26:33 [ main] DEBUG [riverManagerConnectionProvider] - created connection to: jdbc:hsqldb:mem:cat, Isolation Level: 0
> 20:26:33 [ main] INFO [SettingsFactory ] - RDBMS: HSQL Database Engine, version: 1.8.0
> 20:26:33 [ main] INFO [SettingsFactory ] - JDBC driver: HSQL Database Engine Driver, version: 1.8.0
> 20:26:33 [ main] DEBUG [riverManagerConnectionProvider] - returning connection to pool, pool size: 1
> 20:26:33 [ main] INFO [Dialect ] - Using dialect: org.hibernate.dialect.HSQLDialect
> 20:26:33 [ main] INFO [TransactionFactoryFactory] - Using default transaction strategy (direct JDBC transactions)
> 20:26:33 [ main] INFO [ransactionManagerLookupFactory] - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
> 20:26:33 [ main] INFO [SettingsFactory ] - Automatic flush during beforeCompletion(): disabled
> 20:26:33 [ main] INFO [SettingsFactory ] - Automatic session close at end of transaction: disabled
> 20:26:33 [ main] INFO [SettingsFactory ] - JDBC batch size: 15
> 20:26:33 [ main] INFO [SettingsFactory ] - JDBC batch updates for versioned data: disabled
> 20:26:33 [ main] INFO [SettingsFactory ] - Scrollable result sets: enabled
> 20:26:33 [ main] DEBUG [SettingsFactory ] - Wrap result sets: disabled
> 20:26:33 [ main] INFO [SettingsFactory ] - JDBC3 getGeneratedKeys(): disabled
> 20:26:33 [ main] INFO [SettingsFactory ] - Connection release mode: auto
> 20:26:33 [ main] INFO [SettingsFactory ] - Default batch fetch size: 1
> 20:26:33 [ main] INFO [SettingsFactory ] - Generate SQL with comments: disabled
> 20:26:33 [ main] INFO [SettingsFactory ] - Order SQL updates by primary key: disabled
> 20:26:33 [ main] INFO [SettingsFactory ] - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
> 20:26:33 [ main] INFO [ASTQueryTranslatorFactory] - Using ASTQueryTranslatorFactory
> 20:26:33 [ main] INFO [SettingsFactory ] - Query language substitutions: {}
> 20:26:33 [ main] INFO [SettingsFactory ] - Second-level cache: enabled
> 20:26:33 [ main] INFO [SettingsFactory ] - Query cache: disabled
> 20:26:33 [ main] INFO [SettingsFactory ] - Cache provider: org.hibernate.cache.EhCacheProvider
> 20:26:33 [ main] INFO [SettingsFactory ] - Optimize cache for minimal puts: disabled
> 20:26:33 [ main] INFO [SettingsFactory ] - Structured second-level cache entries: disabled
> 20:26:33 [ main] DEBUG [SQLExceptionConverterFactory] - Using dialect defined converter
> 20:26:33 [ main] INFO [SettingsFactory ] - Statistics: disabled
> 20:26:33 [ main] INFO [SettingsFactory ] - Deleted entity synthetic identifier rollback: disabled
> 20:26:33 [ main] INFO [SettingsFactory ] - Default entity-mode: pojo
> 20:26:33 [ main] INFO [SessionFactoryImpl ] - building session factory
> 20:26:33 [ main] DEBUG [SessionFactoryImpl ] - Session factory constructed with filter configurations : {}
> 20:26:33 [ main] DEBUG [SessionFactoryImpl ] - instantiating session factory with properties:
> 20:26:33 [ main] DEBUG [CacheManager ] - Creating new CacheManager with default config
> 20:26:33 [ main] DEBUG [CacheManager ] - Configuring ehcache from classpath.
> 20:26:33 [ main] WARN [Configurator ] - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/C:/idea-workspace/replication/lib/ehcache-1.1.jar!/ehcache-failsafe.xml
> 20:26:33 [ main] DEBUG [Configuration$DiskStore] - Disk Store Path: C:\DOCUME~1\obj\LOCALS~1\Temp\
> 20:26:34 [ main] DEBUG [AbstractEntityPersister] - Static SQL for entity: Cat
> 20:26:34 [ main] DEBUG [AbstractEntityPersister] - Version select: select id from Cat where id =?
> 20:26:34 [ main] DEBUG [AbstractEntityPersister] - Snapshot select: select cat_.id, cat_.abc as abc0_ from Cat cat_ where cat_.id=?
> 20:26:34 [ main] DEBUG [AbstractEntityPersister] - Insert 0: insert into Cat (abc, id) values (?, ?)
> 20:26:34 [ main] DEBUG [AbstractEntityPersister] - Update 0: update Cat set abc=? where id=?
> 20:26:34 [ main] DEBUG [AbstractEntityPersister] - Delete 0: delete from Cat where id=?
> 20:26:34 [ main] DEBUG [AbstractEntityPersister] - Identity insert: insert into Cat (abc, id) values (?, null)
> 20:26:34 [ main] DEBUG [EntityLoader ] - Static select for entity Cat: select cat0_.id as id0_0_, cat0_.abc as abc0_0_ from Cat cat0_ where cat0_.id=?
> 20:26:34 [ main] DEBUG [EntityLoader ] - Static select for entity Cat: select cat0_.id as id0_0_, cat0_.abc as abc0_0_ from Cat cat0_ where cat0_.id=?
> 20:26:34 [ main] DEBUG [EntityLoader ] - Static select for entity Cat: select cat0_.id as id0_0_, cat0_.abc as abc0_0_ from Cat cat0_ where cat0_.id=?
> 20:26:34 [ main] DEBUG [EntityLoader ] - Static select for entity Cat: select cat0_.id as id0_0_, cat0_.abc as abc0_0_ from Cat cat0_ where cat0_.id=?
> 20:26:34 [ main] DEBUG [EntityLoader ] - Static select for action ACTION_MERGE on entity Cat: select cat0_.id as id0_0_, cat0_.abc as abc0_0_ from Cat cat0_ where cat0_.id=?
> 20:26:34 [ main] DEBUG [EntityLoader ] - Static select for action ACTION_REFRESH on entity Cat: select cat0_.id as id0_0_, cat0_.abc as abc0_0_ from Cat cat0_ where cat0_.id=?
> 20:26:34 [ main] DEBUG [SessionFactoryObjectFactory] - initializing class SessionFactoryObjectFactory
> 20:26:34 [ main] DEBUG [SessionFactoryObjectFactory] - registered: 4028810f0a271205010a27120a650000 (unnamed)
> 20:26:34 [ main] INFO [SessionFactoryObjectFactory] - Not binding factory to JNDI, no JNDI name configured
> 20:26:34 [ main] DEBUG [SessionFactoryImpl ] - instantiated session factory
> 20:26:34 [ main] INFO [SchemaUpdate ] - Running hbm2ddl schema update
> 20:26:34 [ main] INFO [SchemaUpdate ] - fetching database metadata
> 20:26:34 [ main] DEBUG [riverManagerConnectionProvider] - total checked-out connections: 0
> 20:26:34 [ main] DEBUG [riverManagerConnectionProvider] - using pooled JDBC connection, pool size: 0
> 20:26:34 [ main] INFO [SchemaUpdate ] - updating schema
> 20:26:34 [ main] DEBUG [Configuration ] - processing extends queue
> 20:26:34 [ main] DEBUG [Configuration ] - processing collection mappings
> 20:26:34 [ main] DEBUG [Configuration ] - processing native query and ResultSetMapping mappings
> 20:26:34 [ main] DEBUG [Configuration ] - processing association property references
> 20:26:34 [ main] DEBUG [Configuration ] - processing foreign key constraints
> 20:26:34 [ main] INFO [DatabaseMetadata ] - table not found: Cat
> 20:26:34 [ main] INFO [DatabaseMetadata ] - table not found: Cat
> 20:26:34 [ main] DEBUG [SchemaUpdate ] - create table Cat (id bigint generated by default as identity (start with 1), abc bit, primary key (id))
> 20:26:34 [ main] INFO [SchemaUpdate ] - schema update complete
> 20:26:34 [ main] DEBUG [riverManagerConnectionProvider] - returning connection to pool, pool size: 1
> 20:26:34 [ main] DEBUG [SessionFactoryImpl ] - Checking 0 named HQL queries
> 20:26:34 [ main] DEBUG [SessionFactoryImpl ] - Checking 0 named SQL queries
> 20:26:34 [ main] INFO [Dialect ] - Using dialect: org.hibernate.dialect.HSQLDialect
> 20:26:34 [ main] INFO [SchemaValidator ] - Running schema validator
> 20:26:34 [ main] INFO [SchemaValidator ] - fetching database metadata
> 20:26:34 [ main] INFO [riverManagerConnectionProvider] - Using Hibernate built-in connection pool (not for production use!)
> 20:26:34 [ main] INFO [riverManagerConnectionProvider] - Hibernate connection pool size: 1
> 20:26:34 [ main] INFO [riverManagerConnectionProvider] - autocommit mode: false
> 20:26:34 [ main] INFO [riverManagerConnectionProvider] - using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:mem:cat
> 20:26:34 [ main] INFO [riverManagerConnectionProvider] - connection properties: {user=sa, password=}
> 20:26:34 [ main] DEBUG [riverManagerConnectionProvider] - total checked-out connections: 0
> 20:26:34 [ main] DEBUG [riverManagerConnectionProvider] - opening new JDBC connection
> 20:26:34 [ main] DEBUG [riverManagerConnectionProvider] - created connection to: jdbc:hsqldb:mem:cat, Isolation Level: 0
> 20:26:34 [ main] DEBUG [Configuration ] - processing extends queue
> 20:26:34 [ main] DEBUG [Configuration ] - processing collection mappings
> 20:26:34 [ main] DEBUG [Configuration ] - processing native query and ResultSetMapping mappings
> 20:26:34 [ main] DEBUG [Configuration ] - processing association property references
> 20:26:34 [ main] DEBUG [Configuration ] - processing foreign key constraints
> 20:26:34 [ main] INFO [TableMetadata ] - table found: PUBLIC.CAT
> 20:26:34 [ main] INFO [TableMetadata ] - columns: [abc, id]
> 20:26:34 [ main] DEBUG [riverManagerConnectionProvider] - returning connection to pool, pool size: 1
> 20:26:34 [ main] INFO [riverManagerConnectionProvider] - cleaning up connection pool: jdbc:hsqldb:mem:cat
> Exception in thread "main" org.hibernate.HibernateException: Wrong column type: abc, expected: bit
> at org.hibernate.mapping.Table.validateColumns(Table.java:219)
> at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:965)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years, 10 months
[Hibernate-JIRA] Created: (HBX-1115) Adding a Spring 2 Exporter to the ant code generation.
by Peter Harrison (JIRA)
Adding a Spring 2 Exporter to the ant code generation.
------------------------------------------------------
Key: HBX-1115
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-1115
Project: Hibernate Tools
Issue Type: Patch
Components: hbm2java
Affects Versions: 3.2beta8
Reporter: Peter Harrison
Priority: Minor
Attachments: springDAO.patch
I'm working on a project using the Hibernate ant tools to generate DAO objects for use inside a Spring context. The existing DAO exporter with suffix "Home" uses JNDI to get the SessionFactory. However, Spring has its own HibernateDaoSupport class which use dependency injection rather than JNDI to determine the Sessionfactory. I could see that the classes I needed were similar to the existing ones, but with modifications to extend the HibernateDaoSupport and the dependency injection approach.
Bottom line is that I have downloaded the source and written a patch for Hibernate Tools to actually create the Spring DAO objects. I essentially copied the existing DAO export code, writing another exporter. The xml is <hbm2springdao>. This addition does not introduce a hibernate dependency on Spring. Although the generated code obviously will depend on Spring there are no compile time dependencies on it introduced into the exporter itself. Is this something you want to include in the main distribution?
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years, 10 months