Return-Path: Delivered-To: apmail-openjpa-users-archive@minotaur.apache.org Received: (qmail 26772 invoked from network); 24 May 2010 15:56:05 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 24 May 2010 15:56:05 -0000 Received: (qmail 79795 invoked by uid 500); 24 May 2010 15:56:05 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 79764 invoked by uid 500); 24 May 2010 15:56:05 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Received: (qmail 79756 invoked by uid 99); 24 May 2010 15:56:05 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 May 2010 15:56:05 +0000 X-ASF-Spam-Status: No, hits=0.7 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [74.125.82.174] (HELO mail-wy0-f174.google.com) (74.125.82.174) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 May 2010 15:55:57 +0000 Received: by wyb29 with SMTP id 29so1684429wyb.33 for ; Mon, 24 May 2010 08:55:37 -0700 (PDT) Received: by 10.216.89.72 with SMTP id b50mr3690274wef.120.1274716536794; Mon, 24 May 2010 08:55:36 -0700 (PDT) Received: from brevsnb005 ([58.165.211.7]) by mx.google.com with ESMTPS id x9sm1112622wej.21.2010.05.24.08.55.33 (version=SSLv3 cipher=RC4-MD5); Mon, 24 May 2010 08:55:36 -0700 (PDT) Reply-To: From: "C N Davies" To: "'KARR, DAVID \(ATTSI\)'" , References: <016101cafb54$7c5f1070$751d3150$@com> In-Reply-To: Subject: RE: OpenJPA confusing classes Date: Tue, 25 May 2010 01:55:27 +1000 Organization: C N Davies Pty Ltd Message-ID: <017401cafb59$8b33cf50$a19b6df0$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: Acr7VHhRgZZbjsofRtGrS1LOn9DmgAAAYVlQAADFmiA= Content-Language: en-au X-Virus-Checked: Checked by ClamAV on apache.org 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 Chris -----Original Message----- From: KARR, DAVID (ATTSI) [mailto:dk068x@att.com] Sent: Tuesday, 25 May 2010 1:33 AM To: users@openjpa.apache.org; cnd@cndavies.com Subject: RE: OpenJPA confusing classes > -----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.