openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "C N Davies" <>
Subject RE: OpenJPA confusing classes
Date Mon, 24 May 2010 15:55:27 GMT
Well that would make sense if I wasn't using table per class. I used this
very same code in 1.2.2 with no issues but 2.0 broke it.

The DB is not enforcing this contraint, it is OpenJPA or more specifically
the cache


-----Original Message-----
Sent: Tuesday, 25 May 2010 1:33 AM
Subject: RE: OpenJPA confusing classes

> -----Original Message-----
> From: C N Davies []
> Sent: Monday, May 24, 2010 8:19 AM
> To:
> 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
> 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.

View raw message