-->
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.  [ 4 posts ] 
Author Message
 Post subject: Bug with entity-name and find by example?
PostPosted: Thu Dec 29, 2005 8:52 pm 
Newbie

Joined: Thu Dec 29, 2005 8:42 pm
Posts: 8
Hi,

There seems to be a problem with using the entity-name attribute and search-by-example. Essentially I have the following mapping file (minus stuff that I think is irrelevant!):

Code:
<class name="MyClass" entity-name="MyClassSummary" ...>
...
</class>

<class name="MyClass" ...>
...
</class>


I then try a find by example, e.g.:

Code:
MyClass obj = new MyClass();
// Set some properties of obj
session.createCriteria(MyClass.class).add(Example.create(obj)).list();


And I get twice as many records back as I am expecting - basically one set for each <class> declaration (I tried it first without the first <class> element above and got the number of records I was expecting).


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 29, 2005 8:58 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Not bug, feature.


Use


public Criteria createCriteria(String entityName);


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 29, 2005 9:17 pm 
Newbie

Joined: Thu Dec 29, 2005 8:42 pm
Posts: 8
OK, I tried:

session.createCriteria(MyClass.class.getName())

and got the same result. I've also explicitly tried setting the entity-name of the second instance to be the same as its class name (rather than assuming hibernate would set the entity-name to the class-name by default)

(Thanks for the quick response BTW)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 29, 2005 9:52 pm 
Newbie

Joined: Thu Dec 29, 2005 8:42 pm
Posts: 8
Changing the mapping declaration to:

<class name="MyClass" entity-name="MyClassSummary" ...>
...
</class>

<class name="MyClass" entity-name="MyClassFull" ...>
...
</class>

end then using session.createCriteria("MyClassFull") works as expected.[/code]


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