Dear developers,
I have a project aiming to use standard JPA data access technology. We're evaluating certain persistence providers right now and have been trying ToplinkEssentials already. As it shows some flaws here and there Hibernate is the next candidate of choice. Unfortunately the Annotation based mapping working in Toplink suddenly raises issues:
Code:
@MappedSuperclass
public abstract class AbstractEntity {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
private User createdBy;
// Getters and Setters
}
@Entity
public class User extends AbstractEntity {
// Properties and stuff...
}
Both classes are registered in persistence.xml. When Hibernate tries to map these classes I get an:
javax.persistence.PersistenceException: org.hibernate.MappingException: Could not determine type for: com.synyx.minos.core.domain.User, for columns: [org.hibernate.mapping.Column(createdBy)]
When I uncomment the createdBy property everything runs fine. I do setup Hibernate (or JPA actually) with Spring 2.5.1 LocalContainerEntityManagerFactoryBean.
The mapping works perfectly in Toplink.
I've been googling a lot but only found results where folks forgot to declare the class in persistence.xml or intermingle XML config with annotations. I don't do both of them.
Is there some stuff, I am missing?
Regards,
Ollie
PS: Here is the console output:
Code:
1:15:12,778 INFO LocalContainerEntityManagerFactoryBean:218 - Building JPA container EntityManagerFactory for persistence unit 'minos'
21:15:12,818 INFO Version:15 - Hibernate Annotations 3.3.0.GA
21:15:12,830 INFO Environment:514 - Hibernate 3.2.5
21:15:12,833 INFO Environment:547 - hibernate.properties not found
21:15:12,835 INFO Environment:681 - Bytecode provider name : cglib
21:15:12,839 INFO Environment:598 - using JDK 1.4 java.sql.Timestamp handling
21:15:12,893 INFO Version:15 - Hibernate EntityManager 3.3.1.GA
21:15:12,912 DEBUG Ejb3Configuration:302 - Processing PersistenceUnitInfo [
name: minos
persistence provider classname: null
classloader: sun.misc.Launcher$AppClassLoader@33056f
Temporary classloader: org.springframework.instrument.classloading.SimpleThrowawayClassLoader@cf3710
excludeUnlistedClasses: false
JTA datasource: null
Non JTA datasource: org.apache.commons.dbcp.BasicDataSource@280492
Transaction type: RESOURCE_LOCAL
PU root URL: file:/Users/olivergierke/Documents/workspace/minos-core/target/classes/
Jar files URLs [
file:/Users/olivergierke/Documents/workspace/minos-core/target/classes/]
Managed classes names [
com.synyx.minos.core.domain.AbstractEntity
com.synyx.minos.core.domain.User
com.synyx.minos.core.domain.Role]
Mapping files names []
Properties []
21:15:12,913 DEBUG Ejb3Configuration:553 - Detect class: true; detect hbm: true
21:15:12,913 DEBUG Ejb3Configuration:553 - Detect class: true; detect hbm: true
21:15:12,966 INFO Ejb3Configuration:678 - found EJB3 @MappedSuperclass: com.synyx.minos.core.domain.AbstractEntity
21:15:12,967 INFO Ejb3Configuration:668 - found EJB3 Entity bean: com.synyx.minos.core.domain.Role
21:15:12,969 INFO Ejb3Configuration:668 - found EJB3 Entity bean: com.synyx.minos.core.domain.User
21:15:12,984 INFO Ejb3Configuration:678 - found EJB3 @MappedSuperclass: com.synyx.minos.core.domain.AbstractEntity
21:15:12,985 INFO Ejb3Configuration:668 - found EJB3 Entity bean: com.synyx.minos.core.domain.Role
21:15:12,985 INFO Ejb3Configuration:668 - found EJB3 Entity bean: com.synyx.minos.core.domain.User
21:15:13,039 DEBUG DTDEntityResolver:38 - trying to resolve system-id [file:///Users/olivergierke/Documents/workspace/minos-core/orm_1_0.xsd]
21:15:13,040 DEBUG EJB3DTDEntityResolver:31 - recognized EJB3 ORM namespace; attempting to resolve on classpath under org/hibernate/ejb
21:15:13,041 DEBUG EJB3DTDEntityResolver:40 - located [file:///Users/olivergierke/Documents/workspace/minos-core/orm_1_0.xsd] in classpath
21:15:13,105 DEBUG DTDEntityResolver:38 - trying to resolve system-id [file:///Users/olivergierke/Documents/workspace/minos-core/orm_1_0.xsd]
21:15:13,106 DEBUG EJB3DTDEntityResolver:31 - recognized EJB3 ORM namespace; attempting to resolve on classpath under org/hibernate/ejb
21:15:13,108 DEBUG EJB3DTDEntityResolver:40 - located [file:///Users/olivergierke/Documents/workspace/minos-core/orm_1_0.xsd] in classpath
21:15:13,187 DEBUG AnnotationConfiguration:244 - Execute first pass mapping processing
21:15:13,274 DEBUG AnnotationConfiguration:481 - Process hbm files
21:15:13,275 DEBUG AnnotationConfiguration:489 - Process annotated classes
21:15:13,279 INFO AnnotationBinder:398 - Binding entity from annotated class: com.synyx.minos.core.domain.User
21:15:13,290 DEBUG Ejb3Column:161 - Binding column DTYPE unique false
21:15:13,309 DEBUG EntityBinder:292 - Import with entity name=User
21:15:13,317 INFO EntityBinder:420 - Bind entity com.synyx.minos.core.domain.User on table User
21:15:13,320 DEBUG AnnotationBinder:983 - Processing com.synyx.minos.core.domain.User property annotation
21:15:13,332 DEBUG AnnotationBinder:983 - Processing com.synyx.minos.core.domain.User property annotation
21:15:13,336 DEBUG AnnotationBinder:983 - Processing com.synyx.minos.core.domain.User field annotation
21:15:13,348 DEBUG AnnotationBinder:983 - Processing com.synyx.minos.core.domain.User field annotation
21:15:13,358 DEBUG AnnotationBinder:1086 - Processing annotations of com.synyx.minos.core.domain.User.id
21:15:13,359 DEBUG Ejb3Column:161 - Binding column id unique false
21:15:13,359 DEBUG AnnotationBinder:1207 - id is an id
21:15:13,364 DEBUG SimpleValueBinder:220 - building SimpleValue for id
21:15:13,366 DEBUG PropertyBinder:128 - Building property id
21:15:13,368 DEBUG PropertyBinder:172 - Cascading id with null
21:15:13,369 DEBUG AnnotationBinder:1244 - Bind @Id on id
21:15:13,371 DEBUG AnnotationBinder:1086 - Processing annotations of com.synyx.minos.core.domain.User.createdBy
21:15:13,371 DEBUG Ejb3Column:161 - Binding column createdBy unique false
21:15:13,371 DEBUG PropertyBinder:106 - binding property createdBy with lazy=false
21:15:13,372 DEBUG SimpleValueBinder:220 - building SimpleValue for createdBy
21:15:13,372 DEBUG PropertyBinder:128 - Building property createdBy
21:15:13,372 DEBUG PropertyBinder:172 - Cascading createdBy with null
21:15:13,374 DEBUG AnnotationBinder:1086 - Processing annotations of com.synyx.minos.core.domain.User.createdDate
21:15:13,374 DEBUG Ejb3Column:161 - Binding column createdDate unique false
21:15:13,374 DEBUG PropertyBinder:106 - binding property createdDate with lazy=false
21:15:13,375 DEBUG SimpleValueBinder:220 - building SimpleValue for createdDate
21:15:13,376 DEBUG PropertyBinder:128 - Building property createdDate
21:15:13,376 DEBUG PropertyBinder:172 - Cascading createdDate with null
21:15:13,378 DEBUG AnnotationBinder:1086 - Processing annotations of com.synyx.minos.core.domain.User.lastModifiedBy
21:15:13,378 DEBUG Ejb3Column:161 - Binding column lastModifiedBy unique false
21:15:13,378 DEBUG PropertyBinder:106 - binding property lastModifiedBy with lazy=false
21:15:13,379 DEBUG SimpleValueBinder:220 - building SimpleValue for lastModifiedBy
21:15:13,379 DEBUG PropertyBinder:128 - Building property lastModifiedBy
21:15:13,380 DEBUG PropertyBinder:172 - Cascading lastModifiedBy with null
21:15:13,380 DEBUG AnnotationBinder:1086 - Processing annotations of com.synyx.minos.core.domain.User.lastModifiedDate
21:15:13,380 DEBUG Ejb3Column:161 - Binding column lastModifiedDate unique false
21:15:13,381 DEBUG PropertyBinder:106 - binding property lastModifiedDate with lazy=false
21:15:13,383 DEBUG SimpleValueBinder:220 - building SimpleValue for lastModifiedDate
21:15:13,383 DEBUG PropertyBinder:128 - Building property lastModifiedDate
21:15:13,384 DEBUG PropertyBinder:172 - Cascading lastModifiedDate with null
21:15:13,384 DEBUG AnnotationBinder:1086 - Processing annotations of com.synyx.minos.core.domain.User.emailAddress
21:15:13,384 DEBUG Ejb3Column:161 - Binding column emailAddress unique true
21:15:13,386 DEBUG PropertyBinder:106 - binding property emailAddress with lazy=false
21:15:13,387 DEBUG SimpleValueBinder:220 - building SimpleValue for emailAddress
21:15:13,387 DEBUG PropertyBinder:128 - Building property emailAddress
21:15:13,388 DEBUG PropertyBinder:172 - Cascading emailAddress with null
21:15:13,388 DEBUG AnnotationBinder:1086 - Processing annotations of com.synyx.minos.core.domain.User.firstname
21:15:13,389 DEBUG Ejb3Column:161 - Binding column firstname unique false
21:15:13,390 DEBUG PropertyBinder:106 - binding property firstname with lazy=false
21:15:13,390 DEBUG SimpleValueBinder:220 - building SimpleValue for firstname
21:15:13,390 DEBUG PropertyBinder:128 - Building property firstname
21:15:13,391 DEBUG PropertyBinder:172 - Cascading firstname with null
21:15:13,391 DEBUG AnnotationBinder:1086 - Processing annotations of com.synyx.minos.core.domain.User.lastname
21:15:13,392 DEBUG Ejb3Column:161 - Binding column lastname unique false
21:15:13,392 DEBUG PropertyBinder:106 - binding property lastname with lazy=false
21:15:13,392 DEBUG SimpleValueBinder:220 - building SimpleValue for lastname
21:15:13,393 DEBUG PropertyBinder:128 - Building property lastname
21:15:13,393 DEBUG PropertyBinder:172 - Cascading lastname with null
21:15:13,394 DEBUG AnnotationBinder:1086 - Processing annotations of com.synyx.minos.core.domain.User.password
21:15:13,394 DEBUG Ejb3Column:161 - Binding column password unique true
21:15:13,394 DEBUG PropertyBinder:106 - binding property password with lazy=false
21:15:13,395 DEBUG SimpleValueBinder:220 - building SimpleValue for password
21:15:13,395 DEBUG PropertyBinder:128 - Building property password
21:15:13,396 DEBUG PropertyBinder:172 - Cascading password with null
21:15:13,396 DEBUG AnnotationBinder:1086 - Processing annotations of com.synyx.minos.core.domain.User.roles
21:15:13,397 DEBUG Ejb3Column:161 - Binding column null unique false
21:15:13,412 DEBUG Ejb3Column:161 - Binding column element unique false
21:15:13,414 DEBUG Ejb3Column:161 - Binding column mapkey unique false
21:15:13,417 DEBUG Ejb3Column:161 - Binding column null unique false
21:15:13,419 DEBUG Ejb3Column:161 - Binding column null unique false
21:15:13,419 DEBUG Ejb3Column:161 - Binding column null unique false
21:15:13,422 DEBUG CollectionBinder:287 - Collection role: com.synyx.minos.core.domain.User.roles
21:15:13,425 DEBUG PropertyBinder:128 - Building property roles
21:15:13,425 DEBUG PropertyBinder:172 - Cascading roles with none
21:15:13,425 DEBUG AnnotationBinder:1086 - Processing annotations of com.synyx.minos.core.domain.User.username
21:15:13,426 DEBUG Ejb3Column:161 - Binding column username unique true
21:15:13,426 DEBUG PropertyBinder:106 - binding property username with lazy=false
21:15:13,427 DEBUG SimpleValueBinder:220 - building SimpleValue for username
21:15:13,427 DEBUG PropertyBinder:128 - Building property username
21:15:13,427 DEBUG PropertyBinder:172 - Cascading username with null
21:15:13,429 INFO AnnotationBinder:398 - Binding entity from annotated class: com.synyx.minos.core.domain.Role
21:15:13,429 DEBUG Ejb3Column:161 - Binding column DTYPE unique false
21:15:13,430 DEBUG EntityBinder:292 - Import with entity name=Role
21:15:13,430 INFO EntityBinder:420 - Bind entity com.synyx.minos.core.domain.Role on table Role
21:15:13,431 DEBUG AnnotationBinder:983 - Processing com.synyx.minos.core.domain.Role property annotation
21:15:13,432 DEBUG AnnotationBinder:983 - Processing com.synyx.minos.core.domain.Role property annotation
21:15:13,432 DEBUG AnnotationBinder:983 - Processing com.synyx.minos.core.domain.Role field annotation
21:15:13,433 DEBUG AnnotationBinder:983 - Processing com.synyx.minos.core.domain.Role field annotation
21:15:13,433 DEBUG AnnotationBinder:1086 - Processing annotations of com.synyx.minos.core.domain.Role.id
21:15:13,433 DEBUG Ejb3Column:161 - Binding column id unique false
21:15:13,435 DEBUG AnnotationBinder:1207 - id is an id
21:15:13,435 DEBUG SimpleValueBinder:220 - building SimpleValue for id
21:15:13,436 DEBUG PropertyBinder:128 - Building property id
21:15:13,437 DEBUG PropertyBinder:172 - Cascading id with null
21:15:13,437 DEBUG AnnotationBinder:1244 - Bind @Id on id
21:15:13,437 DEBUG AnnotationBinder:1086 - Processing annotations of com.synyx.minos.core.domain.Role.createdBy
21:15:13,441 DEBUG Ejb3Column:161 - Binding column createdBy unique false
21:15:13,441 DEBUG PropertyBinder:106 - binding property createdBy with lazy=false
21:15:13,441 DEBUG SimpleValueBinder:220 - building SimpleValue for createdBy
21:15:13,442 DEBUG PropertyBinder:128 - Building property createdBy
21:15:13,442 DEBUG PropertyBinder:172 - Cascading createdBy with null
21:15:13,443 DEBUG AnnotationBinder:1086 - Processing annotations of com.synyx.minos.core.domain.Role.createdDate
21:15:13,443 DEBUG Ejb3Column:161 - Binding column createdDate unique false
21:15:13,443 DEBUG PropertyBinder:106 - binding property createdDate with lazy=false
21:15:13,444 DEBUG SimpleValueBinder:220 - building SimpleValue for createdDate
21:15:13,444 DEBUG PropertyBinder:128 - Building property createdDate
21:15:13,445 DEBUG PropertyBinder:172 - Cascading createdDate with null
21:15:13,446 DEBUG AnnotationBinder:1086 - Processing annotations of com.synyx.minos.core.domain.Role.lastModifiedBy
21:15:13,446 DEBUG Ejb3Column:161 - Binding column lastModifiedBy unique false
21:15:13,447 DEBUG PropertyBinder:106 - binding property lastModifiedBy with lazy=false
21:15:13,447 DEBUG SimpleValueBinder:220 - building SimpleValue for lastModifiedBy
21:15:13,448 DEBUG PropertyBinder:128 - Building property lastModifiedBy
21:15:13,448 DEBUG PropertyBinder:172 - Cascading lastModifiedBy with null
21:15:13,449 DEBUG AnnotationBinder:1086 - Processing annotations of com.synyx.minos.core.domain.Role.lastModifiedDate
21:15:13,449 DEBUG Ejb3Column:161 - Binding column lastModifiedDate unique false
21:15:13,449 DEBUG PropertyBinder:106 - binding property lastModifiedDate with lazy=false
21:15:13,450 DEBUG SimpleValueBinder:220 - building SimpleValue for lastModifiedDate
21:15:13,450 DEBUG PropertyBinder:128 - Building property lastModifiedDate
21:15:13,451 DEBUG PropertyBinder:172 - Cascading lastModifiedDate with null
21:15:13,451 DEBUG AnnotationBinder:1086 - Processing annotations of com.synyx.minos.core.domain.Role.name
21:15:13,451 DEBUG Ejb3Column:161 - Binding column name unique false
21:15:13,451 DEBUG PropertyBinder:106 - binding property name with lazy=false
21:15:13,453 DEBUG SimpleValueBinder:220 - building SimpleValue for name
21:15:13,453 DEBUG PropertyBinder:128 - Building property name
21:15:13,454 DEBUG PropertyBinder:172 - Cascading name with null
21:15:13,454 DEBUG AnnotationConfiguration:375 - processing manytoone fk mappings
21:15:13,458 DEBUG Configuration:1120 - processing extends queue
21:15:13,458 DEBUG Configuration:1124 - processing collection mappings
21:15:13,459 DEBUG CollectionSecondPass:41 - Second pass for collection: com.synyx.minos.core.domain.User.roles
21:15:13,459 DEBUG CollectionBinder:1023 - Binding as ManyToMany: com.synyx.minos.core.domain.User.roles
21:15:13,520 DEBUG CollectionSecondPass:57 - Mapped collection key: User_id, element: roles_id
21:15:13,521 DEBUG Configuration:1135 - processing native query and ResultSetMapping mappings
21:15:13,521 DEBUG Configuration:1143 - processing association property references
21:15:13,522 DEBUG Configuration:1165 - processing foreign key constraints
21:15:13,523 DEBUG Configuration:1248 - resolving reference to class: com.synyx.minos.core.domain.User
21:15:13,524 DEBUG Configuration:1248 - resolving reference to class: com.synyx.minos.core.domain.Role
21:15:13,529 INFO Version:17 - Hibernate Validator 3.0.0.GA
21:15:13,532 DEBUG ClassValidator:167 - ResourceBundle ValidatorMessages not found in thread context classloader
21:15:13,532 DEBUG ClassValidator:177 - ResourceBundle ValidatorMessages not found in Validator classloader. Delegate to org.hibernate.validator.resources.DefaultValidatorMessages
21:15:13,541 DEBUG ClassValidator:167 - ResourceBundle ValidatorMessages not found in thread context classloader
21:15:13,542 DEBUG ClassValidator:177 - ResourceBundle ValidatorMessages not found in Validator classloader. Delegate to org.hibernate.validator.resources.DefaultValidatorMessages
21:15:13,558 DEBUG NamingHelper:30 - No JNDI name configured for binding Ejb3Configuration
21:15:13,562 DEBUG AnnotationConfiguration:831 - Search not present in classpath, ignoring event listener registration
21:15:13,563 DEBUG Configuration:1285 - Preparing to build session factory with filters : {}
21:15:13,563 DEBUG AnnotationConfiguration:244 - Execute first pass mapping processing
21:15:13,563 DEBUG AnnotationConfiguration:481 - Process hbm files
21:15:13,564 DEBUG AnnotationConfiguration:489 - Process annotated classes
21:15:13,564 DEBUG AnnotationConfiguration:375 - processing manytoone fk mappings
21:15:13,565 DEBUG Configuration:1120 - processing extends queue
21:15:13,566 DEBUG Configuration:1124 - processing collection mappings
21:15:13,566 DEBUG Configuration:1135 - processing native query and ResultSetMapping mappings
21:15:13,566 DEBUG Configuration:1143 - processing association property references
21:15:13,566 DEBUG Configuration:1165 - processing foreign key constraints
21:15:13,567 DEBUG Configuration:1248 - resolving reference to class: com.synyx.minos.core.domain.User
21:15:13,567 DEBUG Configuration:1248 - resolving reference to class: com.synyx.minos.core.domain.Role
21:15:13,568 DEBUG ClassValidator:167 - ResourceBundle ValidatorMessages not found in thread context classloader
21:15:13,568 DEBUG ClassValidator:177 - ResourceBundle ValidatorMessages not found in Validator classloader. Delegate to org.hibernate.validator.resources.DefaultValidatorMessages
21:15:13,574 DEBUG ClassValidator:167 - ResourceBundle ValidatorMessages not found in thread context classloader
21:15:13,574 DEBUG ClassValidator:177 - ResourceBundle ValidatorMessages not found in Validator classloader. Delegate to org.hibernate.validator.resources.DefaultValidatorMessages
21:15:13,578 INFO DefaultListableBeanFactory:340 - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@12d7ae: defining beans [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0,dataSource,persistenceUnitManager,entityManagerFactory,org.springframework.orm.jpa.JpaTransactionManager#0]; root of factory hierarchy