Query by Class question and potential problem [message #603594] |
Wed, 14 March 2007 01:48 |
Jean-Denis Boudreault Messages: 55 Registered: July 2009 |
Member |
|
|
Hello,
i am currently porting my old POJO/hibernate code to
EMF/Teneo/Hibernate. for many queries, i used to query by "load" or
"get" and specifying the class name.
i.e.: List myObjects =
this.getHibernateTemplate().loadAll(MyObjectImpl.class);
what happens is an exception saying that the object MyObject is not
defined.
<exception>Caused by: org.hibernate.MappingException: Unknown entity:
com.something.model.impl.MyObjectImpl</exception>
Since this code used to work before teneo, i realized that it was due to
the interface / implementation of EMF.
Basically, if it is in the package "pack1.pack2", the it will create an
interface at:
pack1.pack2.MyObject
and it will create an implementation at:
pack1.pack2.impl.MyObjectImpl.
Teneo gives the interface name to the mapped entity in the hbm.xml file
(i.e. entity-name="MyObject"), and this seems to cause problems when
invoking by class type. If i provide the interface name, then it wont
work since hibernate expects the implementation. but if i use the
implementation, the name does not match the mapped entity.
If i query by string class name (or by query), all works fine. (as
expressed in the examples on the elver site)
my question is: is there a way to query by class type in teneo, or must
we explicitly provide the type by string name? perhaps can we force the
entity name in the hbm file to be the implementation one? and is this a
known limitation or am i missing something?
thanks a lot for your invaluable help!
|
|
|
Powered by
FUDForum. Page generated in 0.02555 seconds