-->
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: Criteria not being generated for super class information?
PostPosted: Sun Jan 08, 2006 9:34 pm 
Beginner
Beginner

Joined: Sun Jun 05, 2005 9:45 am
Posts: 27
"Consumer" is a joined subclass of "Party". The "Party" class contains a member variable "partyId".

If I were to create a Consumer object and set the partyId = 2, the partyId is never reflected in the generated sql where clause. Looking at the API for Session.createCriteria(), it says:

Quote:
Create a new Criteria instance, for the given entity class, or a superclass of an entity class.


I did not see that you anything that indicates that you need to handle superclasses differently. Am I doing this wrong? Here is what I am using in my Dao:

Code:
    public Consumer getByExample(final Consumer example) {
        HibernateCallback callback = new HibernateCallback() {
            public Object doInHibernate(Session session) throws HibernateException {
                Criteria crit = session.createCriteria(Consumer.class);
                crit.add(Example.create(example));
                return (Consumer)crit.uniqueResult();
            }
        };
        return (Consumer)getHibernateTemplate().execute(callback);
    }


Your suggestions would be greatly appreciated.

Regards,

Joshua


Top
 Profile  
 
 Post subject: Do you really have to run Example.create for every class ...
PostPosted: Mon Jan 09, 2006 9:05 am 
Beginner
Beginner

Joined: Sun Jun 05, 2005 9:45 am
Posts: 27
Do you really have to run Example.create() for every class in a class hierarchy?


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.