|
Re: polymorphism="explicit" not working for Criteriaor load Query [message #431819 is a reply to message #431799] |
Mon, 27 July 2009 20:21 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Ajay,
I have never used polymorphism="explicit"....
So I am not sure that I can really help here. I would debug hibernate and enable log4j logging for hibernate to see
which queries are executed.
To help you in this here are some common issues I encounter myself when working with log4j:
- your log4j.properties file is not read because there is already another log4j.properties file read. To debug this add
the -Dlog4j.debug jvm argument, then log4j will print the location it reads the log4j.properties from.
- no log4j library on the classpath (then automatically java logging is used but your log4j.properties is ignored)
- log4j.properties is not copied to the output path, add it to the build.properties
gr. Martin
Ajay Chauhan wrote:
> Hello Martin,
>
> I have got Two classes mapped to the same Database Table(Person), and i
> need to use polymorphism="explicit" feature of hibernate.I am creating
> my own hibernate files for which i have set PersistenceOptions as
> USE_MAPPING_FILE= TRUE.The Inheritance hierarchy in EMF class is
> GreetPerson extending Person.
>
> My hbm file definition is as mentioned below:
>
> Person.hbm.xml:
> <class
> name="com.foo.PersonImpl"
> table="Person" entity-name="Person" dynamic-update="false"
> dynamic-insert="false" select-before-update="false" lazy="false"
> abstract="false" >
>
>
> GreetPerson.hbm.xml:
> <class
> name="com.foo.GreetPersonImpl"
> table="Person" entity-name="GreetPerson" dynamic-update="false"
> dynamic-insert="false" select-before-update="false" lazy="false"
> abstract="false" polymorhism="explicit">
>
>
> Now, when i am using the Criteria Query/ Simple loadQuery I am not
> getting any results i.e. The result is null. Although there are no
> exceptions being thrown from Hibernate, but i get an empty result.
> However, if i remove polymorphism ="explicit" from the
> GreetPerson.hbm.xml i get results.
>
> Could you please let me know how i can use polymorphism="explicit" for
> the same case?
>
> Thanks and Regards,
> Ajay Chauhan
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Re: polymorphism="explicit" not working for Criteriaor load Query [message #431851 is a reply to message #431819] |
Tue, 28 July 2009 09:06 |
Ajay Messages: 12 Registered: July 2009 |
Junior Member |
|
|
Hello Martin,
Thanks for your quick reply.
There are no queries executed by hibernate when i apply
polymorphism="explicit" neither in Criteria query nor in createQuery.
Actually,i have debugged the hibernate code and the problem is in
SessionFactoryImpl#getImplementors(String className), where
if we specify polymorphism="explicit" then it checks for the equality of
EntityName with the classname which it gets
through Reflection.
For example:
GreetPerson.hbm.xml:
<class name="com.foo.GreetPersonImpl"
table="Person" entity-name="GreetPerson" dynamic-update="false"
dynamic-insert="false" select-before-update="false" lazy="false"
abstract="false" polymorhism="explicit">
In this case,EntityName will be "GreetPerson" and className will be
"com.foo.GreetPerson", hence the equality
check fails and no queries are executed by Hibernate.
I tried the similar option with hibernate without Teneo and without EMF
classes which works,as in that case entity-name is same as classname.
The problem will be rectified if there is a way where the fully qualified
name of entity can be specified in entity-name i.e.
instead of entity-name="GreetPerson", entity-name="com.foo.GreetPerson",
which i have tried but it fails by giving the following exception:
Caused by: java.lang.NullPointerException
at
org.eclipse.emf.teneo.util.StoreUtil.getEStructuralFeature(S toreUtil.java:360)
at
org.eclipse.emf.teneo.hibernate.HbUtil.getPropertyAccessor(H bUtil.java:123)
at
org.eclipse.emf.teneo.hibernate.tuplizer.EMFTuplizer.getProp ertyAccessor(EMFTuplizer.java:264)
at
org.eclipse.emf.teneo.hibernate.tuplizer.EMFTuplizer.buildPr opertyGetter(EMFTuplizer.java:139)
at
org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:129)
at
org.eclipse.emf.teneo.hibernate.tuplizer.EMFTuplizer.<init>(EMFTuplizer.java:76)
... 79 more
BTW the Teneo Version that i am using is 1.0.1
Thanks and Regards,
Ajay chauhan
|
|
|
Re: polymorphism="explicit" not working for Criteriaor load Query [message #431867 is a reply to message #431851] |
Tue, 28 July 2009 13:14 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Ajay,
Ok clear, can you enter a bugzilla for this with a copy of your last post? Then I can take a look. It seems that some
work needs to be done to get the Teneo entitynaming inline with polymorphism=explicit (or adapt Hibernate).
gr. Martin
Ajay Chauhan wrote:
> Hello Martin,
>
> Thanks for your quick reply.
>
> There are no queries executed by hibernate when i apply
> polymorphism="explicit" neither in Criteria query nor in createQuery.
> Actually,i have debugged the hibernate code and the problem is in
> SessionFactoryImpl#getImplementors(String className), where if we
> specify polymorphism="explicit" then it checks for the equality of
> EntityName with the classname which it gets through Reflection.
>
> For example:
> GreetPerson.hbm.xml:
>
> <class name="com.foo.GreetPersonImpl"
> table="Person" entity-name="GreetPerson" dynamic-update="false"
> dynamic-insert="false" select-before-update="false" lazy="false"
> abstract="false" polymorhism="explicit">
>
> In this case,EntityName will be "GreetPerson" and className will be
> "com.foo.GreetPerson", hence the equality check fails and no queries are
> executed by Hibernate.
>
> I tried the similar option with hibernate without Teneo and without EMF
> classes which works,as in that case entity-name is same as classname.
>
>
> The problem will be rectified if there is a way where the fully
> qualified name of entity can be specified in entity-name i.e. instead of
> entity-name="GreetPerson", entity-name="com.foo.GreetPerson", which i
> have tried but it fails by giving the following exception:
>
> Caused by: java.lang.NullPointerException
> at
> org.eclipse.emf.teneo.util.StoreUtil.getEStructuralFeature(S toreUtil.java:360)
>
> at
> org.eclipse.emf.teneo.hibernate.HbUtil.getPropertyAccessor(H bUtil.java:123)
> at
> org.eclipse.emf.teneo.hibernate.tuplizer.EMFTuplizer.getProp ertyAccessor(EMFTuplizer.java:264)
>
> at
> org.eclipse.emf.teneo.hibernate.tuplizer.EMFTuplizer.buildPr opertyGetter(EMFTuplizer.java:139)
>
> at
> org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:129)
>
> at
> org.eclipse.emf.teneo.hibernate.tuplizer.EMFTuplizer.<init>(EMFTuplizer.java:76)
>
> ... 79 more
>
>
> BTW the Teneo Version that i am using is 1.0.1
>
> Thanks and Regards,
> Ajay chauhan
>
>
>
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Powered by
FUDForum. Page generated in 0.03164 seconds