-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: "Could not determine type for" could be more helpf
PostPosted: Tue Jun 06, 2006 7:43 pm 
Newbie

Joined: Thu Jun 16, 2005 5:21 pm
Posts: 6
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


Top
 Profile  
 
 Post subject: Similar problem caused by mixing field/method Annotations
PostPosted: Thu Jun 08, 2006 5:52 pm 
Regular
Regular

Joined: Sun Sep 21, 2003 11:43 pm
Posts: 85
Location: Massachusetts
I finally figured out I was seeing that problem because I violated the #1 annotations rule: Use all field or all method annotations, do not mix both.

Yes, in not one but TWO classes, I had @Id and @Basic annotations on the fields while mistakenly putting @ManyToMany annotations on the getter methods. I was using a setup similar to yours: Hibernate 3.2 cr2 and Hibernate Annotations 3.2.0.CR1. And my error message was for my selected collection type of java.util.Set:

> org.hibernate.MappingException: Could not determine
> type for: java.util.Set, for columns:
> org.hibernate.mapping.Column(users

I hope this information helps others diagnose their own issues more quickly.

Regards,
David


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.