openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "KARR, DAVID (ATTSI)" <dk0...@att.com>
Subject RE: OpenJPA confusing classes
Date Mon, 24 May 2010 15:32:57 GMT
> -----Original Message-----
> From: C N Davies [mailto:cnd@cndavies.com]
> Sent: Monday, May 24, 2010 8:19 AM
> To: users@openjpa.apache.org
> Subject: OpenJPA confusing classes
> 
> Here's a snippet of my ode,
> 
>             (Department) es.find(Department.class, "N/A");
> 
>             (PrintQueue) es.find(PrintQueue.class, "N/A");
> 
> Both Department and PrintQueue entities are based upon the same super
> class
> but I use table per class so they are in separate tables.
> 
> As you can see they both have the same key, but if I put the
department
> line
> 1st the find of the print queue will generate a class cast exception
> trying
> to cast a Department to a PrintQueue. If I put the PrintQueue line 1st
> I
> will get a class cast exception trying to cast a PrintQueue to  a
> Department.  The second find doesn't generate any SQL  if I have trace
> logging turned on so it looks to me that it is a cache issue.
> 
> I can't see anything like this in the JIRA is it a known bug or not?

I would assume keys in an inheritance tree have to be unique across the
hierarchy.  If not, then there's no way to tell what object it really
refers to.  The CCEs are due to the fact that caching in the session
uses the PK as the key (obviously).  You already loaded a Department
with that PK, so the reference on the next line is going to load it from
the session, which blows up.

Mime
View raw message