openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Grenier Nicolas" <Nicolas.Gren...@atosorigin.com>
Subject RE: Find by primary key does not return the real type of a record but instance of the type passed as parameter
Date Thu, 12 Oct 2006 14:22:35 GMT
Thanks for your reply Patrick.

My classes use the JOINED inheritance strategy. I use the default basic mappings and a sequence
generator inside the root class.
I've joined the real classes, in fact the names of my classes are as follow (I renamed them
in my previous mail for simplicity):

Channel <- CommerceChannel <- Networking | Peripherals | Components

It is a simple eCommerce Web site which manage categories (channels) which contains products.
Products hierarchy is as follows:

Product <- CommerceProduct <- Keyboard | Mouse | ...

The error occurred when I try to get a specific channel, I get a Channel class instead of
a Components one.

Sincerely,

Nicolas.


-----Message d'origine-----
De : Patrick Linskey [mailto:plinskey@bea.com] 
Envoyé : jeudi 12 octobre 2006 15:24
À : open-jpa-dev@incubator.apache.org
Objet : RE: Find by primary key does not return the real type of a record but instance of
the type passed as parameter

Can you provide some information about how your classes are mapped to
the database? In particular, it'd be interesting to learn about your
subclass mapping strategy.

Also, what version of OpenJPA are you using? (java
org.apache.openjpa.conf.OpenJPAVersion)

This is not expected behavior.

-Patrick

-- 
Patrick Linskey
BEA Systems, Inc. 

_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it. 

> -----Original Message-----
> From: Grenier Nicolas [mailto:Nicolas.Grenier@atosorigin.com] 
> Sent: Thursday, October 12, 2006 2:59 AM
> To: open-jpa-dev@incubator.apache.org
> Subject: Find by primary key does not return the real type of 
> a record but instance of the type passed as parameter
> 
> Hello,
> 
> I have developed a small test application using OpenJPA 
> (fresh checkout)
> in which I have the following class hierarchy:
> 
> 	RootEntityClass <- ChildMappedClass <- LeafEntityClass
> 
> In my application I do a find by primary key using the entity manager
> like this:
> 
> 	LeafEntityClass myLeaf = (LeafEntityClass)entityManager.find
> (RootEntityClass.class, id);
> 
> I know that I can only get a Leaf instance (I've only such records in
> database) so I attempt to cast it to the Leaf type. 
> This code works fine with Hibernate but with OpenJPA, the 
> entity manager
> returns instances of RootEntityClass and not LeafEntityClass.
> 
> Is this a bug ; specifications are not very clear concerning the find
> method behaviour ?
> 
> Thanks in advance.
> 
> Nicolas.
> 
> 
> 




Mime
View raw message