Hibernate 3.2 cr2
Hibernate Annotations 3.2.0.CR1
Hibernate EntityManager 3.2.0.CR1
In porting my Hibernate application to EJB3 Persistence I've encountered the following error on several occasions:
Building EntityManagerFactory failed: org.hibernate.MappingException: Could not determine type for: java.util.Collection, for columns: [org.hibernate.mapping.Column(attributeKinds)]
I've searched for "Could not determine type for: java.util.Collection" and there are a few hits, but none of them seem to resolve this from the angle I'm seeing it.
I know this means I have a mistake in my mapping - that's not the issue I'm raising. What I'm finding is that this message isn't helpful enough to enable me to identify my mapping errors in a reasonable amount of time.
I have many classes with EJB3 annotations in them. All this message says to me in its current form is "you made a mistake somewhere". It's lacking sufficient context to nail down the specific mapping/annotations problem. Turning on debug logging doesn't give any additional context or help. In this case the problem is because I missed an @Transient (so it defaults to @Basic and tries to map it) on the following method in my "DefinedRoleImpl" entity class:
public Collection<AttributeKind> getAttributeKinds() {
You'll note that the error message contains "attributeKinds", but this isn't in the method signature or class name. Compare this to the following message for a different mapping error:
Caused by: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on com.borland.helios.aethon.metamodel.impl.ProcessAttributeImpl.child references an unknown entity: com.borland.helios.aethon.metamodel.AttributeKind
This immediately tells me where to go look for my mistake.
Are other user's finding this?
The ideal improvement would be to include the file and line number the offending annotation came from, but I doubt that's possible given the information available from Java's annotations API (and there is the added complexity of orm.xml as a mapping source). However, what should be possible is to include the entity class name in the message (just as it is in the @OneToOne message example I quote). Does this make sense?
Regards,
Olli
|