[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-613) search by criteria with sub-class Example do not bind sub-class properties

Paul Benedict (JIRA) noreply at atlassian.com
Tue Mar 18 10:43:33 EDT 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-613?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_29827 ] 

Paul Benedict commented on HHH-613:
-----------------------------------

Ah. I see. If you create a criteria of the supertype and make an example of the subtype, it obviously will not work. As Gavin said, this is correct behavior. You need to actually create an example of the subtype.

> search by criteria with sub-class Example do not bind sub-class properties
> --------------------------------------------------------------------------
>
>                 Key: HHH-613
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-613
>             Project: Hibernate3
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.0.5
>            Reporter: Foaloke
>            Priority: Blocker
>
> class Animal {
>   private Int age;
>   ...
> }
> class Pet extends Animal {
>   private String name;
>   ...
> }
> Pet pet = new Pet();
> pet.setName("Fritz");
> session.createCriteria(Animal.class).add(Example.create(pet)).list();
> This will simply return all 'Pets', no binding occurs with the "name" property of Pet.
> This could, more probably, occurs if I have some Country which contains Animals & I want to look for some kind of Pets in that country :
> session.createCriteria(Country.class).createCriteria("animal").add(Example.create(pet)).list();

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list