-->
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.  [ 5 posts ] 
Author Message
 Post subject: strange problem with entity mapping
PostPosted: Tue Nov 08, 2005 12:52 pm 
Beginner
Beginner

Joined: Thu Oct 20, 2005 1:03 pm
Posts: 38
Has anyone run into this?

I get a org.hibernate.MappingException: Unknown entity when I try to build the class name like this in a createCriteria but not when I hardcode the class name:

Criteria q = session.createCriteria(className+".class");

I have verified that the class name is building correctly and the string is identical to the hardcoded string.

Any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 08, 2005 1:21 pm 
Senior
Senior

Joined: Mon Apr 04, 2005 8:04 am
Posts: 128
Location: Manchester, NH USA
Umm. That is because:

"Job.class" != Job.class

The former is a string, the latter is a reference to Job's Class object.

"Job" or Job.class will work, but not what you're doing.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 08, 2005 2:18 pm 
Beginner
Beginner

Joined: Thu Oct 20, 2005 1:03 pm
Posts: 38
Oh of course! I kept thinking that the the method would pick up the String variable's value but I guess that would mean that there needs to be a method that takes a String in addition to a method that takes a class. doh! I feel so stupid! Thanks!

PS - I think this would be a nice enhancement.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 08, 2005 3:21 pm 
Senior
Senior

Joined: Mon Apr 04, 2005 8:04 am
Posts: 128
Location: Manchester, NH USA
No, to clarify - there is a method that takes a string. Your problem was that the format of the string you were trying to use was wrong. The string you were trying to use was "Job.class" and should have been "Job". Does that make sense?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 14, 2005 9:54 am 
Beginner
Beginner

Joined: Thu Oct 20, 2005 1:03 pm
Posts: 38
pmularien wrote:
No, to clarify - there is a method that takes a string. Your problem was that the format of the string you were trying to use was wrong. The string you were trying to use was "Job.class" and should have been "Job". Does that make sense?


Yes, thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.