From dev-return-14279-apmail-openjpa-dev-archive=openjpa.apache.org@openjpa.apache.org Sat Nov 21 03:41:36 2009 Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 65772 invoked from network); 21 Nov 2009 03:41:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 21 Nov 2009 03:41:36 -0000 Received: (qmail 14437 invoked by uid 500); 21 Nov 2009 03:41:36 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 14270 invoked by uid 500); 21 Nov 2009 03:41:35 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Delivered-To: moderator for dev@openjpa.apache.org Received: (qmail 19724 invoked by uid 99); 21 Nov 2009 01:08:17 -0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of stefan.wokusch@gmx.de designates 213.165.64.20 as permitted sender) X-Authenticated: #10306765 X-Provags-ID: V01U2FsdGVkX1+Onb1F3kKOfbA3iloVald9mh0Hw0pJj8OImTG7By 61Zby4gyKsJl69 Message-ID: <4B073D63.40304@gmx.de> Date: Sat, 21 Nov 2009 02:07:47 +0100 From: Stefan Wokusch User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: dev@openjpa.apache.org Subject: Inheritance with Listgetter Bug Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-FuHaFi: 0.42 X-Virus-Checked: Checked by ClamAV on apache.org Hello Team, I have a Problem with my OpenJPA, and i think its a bug. The Getter/Proxy dont get all elements of a List. Following the complete Testcase scenario: For the test the following Settings are used. Cache have to be disabled, otherwise the test will pass because cached data. persistence.xml:: ... hellojpa.T1 hellojpa.T2 hellojpa.T3 // Using Mysql but i think the prob is the query it selves :) ... My Entityclasses: @Entity @Inheritance(strategy=InheritanceType.SINGLE_TABLE) public class T1 { @Id @GeneratedValue private Integer id; public void setId(Integer id) { this.id = id; } public Integer getId() { return id; } } @Entity public class T2 extends T1{ @OneToMany(fetch=FetchType.LAZY, cascade=CascadeType.PERSIST) private List t2List; public void setT1List(List t2List) { this.t2List = t2List; } public List getT2List() { return t2List; } } @Entity public class T3 extends T2 { } We have 3 Classes on the top of each other, at the middle a List with T2s. My Testclasses: private static void commit(){ em.getTransaction().begin(); em.getTransaction().commit(); } // Create a TestEntity T2 t2 = new T2(); em.persist(t2); commit(); // Put a T2 t2.getT2List().add(new T2()); commit(); em.refresh(t2); // important to cause a new DB-Query. assert(t2.getT2List().size()==1); // its *OK* // Put a T3 t2.getT2List().add(new T3()); commit(); em.refresh(t2); // important to cause a new DB-Query. assert(t2.getT2List().size()==2);// it *FAILS* Database after the Test: T1: id -> DTYPE 51 -> T2 52 -> T2 53 -> T3 T1_T1 T2_ID -> T2_T2LIST 51 -> 52 51 -> 53 In the Database, there are both Elements correctly. I think the Problem is, that OpenJPA creates the following SQL-Queries: SELECT t1.id, t1.DTYPE FROM T1_T1 t0 INNER JOIN T1 t1 ON t0.T2_ID = t1.id WHERE t0.T2_ID = ? AND *t1.DTYPE = ? * [params=(int) 3601, (String) *T2*] So the T3 Entities would be ignored. in this query. Did anyone have an Idea why jpa makes such a strange query with ignoring the subclasses of T2. My other trys: - Marks with @Nonpolymorphic(NonpolymorphicType.JOINABLE) - Marks with @ElementNonpolymorphic(NonpolymorphicType.JOINABLE) - Take Set instead of List - The Scenario without a List and a Single Relation would pass and gets an query with t1.DTYPE IN (T2, T3). So its only with Lists. Hope for help Stefan