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