-->
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.  [ 1 post ] 
Author Message
 Post subject: POJO Object Inheritance and Mappings
PostPosted: Tue Jul 18, 2006 10:58 am 
Newbie

Joined: Tue Jul 18, 2006 10:47 am
Posts: 2
Location: Saint Louis, MO
Can anyone shed some light on why the following isn't working? It might be an POJO object inheritence thing.

Code:
            Object object = new Power();

        //this one throws a ClassCastException.
           getHibernateTemplate().findByExample(object);

        //this one will work fine and returns a resultset.
           getHibernateTemplate().find("from Power");
                 //in directly calls hibernate using HSQL.
                 --session.createQuery(queryString); 

My Pojo Layer looks like this.

+Power
+---ElectricalDevice

I have two database tables for each and two separate mapping files for each and they "are not" subclassed in the mapping.

My goal is to just perform a Select * from table (without a where clause)....or all of the records.
I want to retrieve only power records and not both power and electrical device records. Both are returned because electrical device is a subclass.

I have read about if you perform a retrieve on say "from Object" hibernate will get basically everything from every database table. But, how can I get around or disable this.

Also, ever since I subclassed Power, now my retrieves using findByExample() are failing.

Can you not use findByExample() when using subclassed objects? Or maybe it's a mapping thing.

These are some spring calls, but they also call hibernate.

Thanks for any help.

Nick


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

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.