Return-Path: Delivered-To: apmail-openjpa-users-archive@minotaur.apache.org Received: (qmail 56296 invoked from network); 29 Mar 2009 20:17:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 29 Mar 2009 20:17:45 -0000 Received: (qmail 78208 invoked by uid 500); 29 Mar 2009 20:17:44 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 78126 invoked by uid 500); 29 Mar 2009 20:17:44 -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 78114 invoked by uid 99); 29 Mar 2009 20:17:44 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 29 Mar 2009 20:17:44 +0000 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of richard.rak@gmail.com designates 74.125.44.29 as permitted sender) Received: from [74.125.44.29] (HELO yx-out-2324.google.com) (74.125.44.29) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 29 Mar 2009 20:17:33 +0000 Received: by yx-out-2324.google.com with SMTP id 3so1028211yxj.63 for ; Sun, 29 Mar 2009 13:17:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to :in-reply-to:content-type:content-transfer-encoding:mime-version :subject:date:references:x-mailer; bh=M0bksHpMH99oGXZzh4Pr9JyxtDXe/SuDODrLcdlp+mk=; b=E3/RMRFgGxe2Wqo012dlcwaj0lmDtxn1d++Fvp2k48COBQM044PuYQf8/ZmNWxaya4 /ogJ2EnvAiWJYqffTP3zeLAONDaAGrxI1twlGShH6khhEJpsLqYolwxBIHoK4nD25Z7I 5aZ8Wz1R0Sn3bIPaHsCRA1TIoHs6SZ9EXkClU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:in-reply-to:content-type :content-transfer-encoding:mime-version:subject:date:references :x-mailer; b=QjHang/6oU1XuIwzGNCteVWadTfWY8MREsy6Yh1oHDLpAVbCh9KnGSWWgGXeomMNke LxcPrs/MFAdZWv1ET031KQmcqbtAT2Hvjxj+BRh0jGonmGTutpgOJzMXg+YFP6A77L66 6R0JRjNsdPS+mgLVu3CXztcmpKz5yFvmWRAko= Received: by 10.90.101.7 with SMTP id y7mr2019022agb.62.1238357831840; Sun, 29 Mar 2009 13:17:11 -0700 (PDT) Received: from ?192.168.0.101? (d39-2-166.home1.cgocable.net [72.39.2.166]) by mx.google.com with ESMTPS id 30sm4606888agc.9.2009.03.29.13.17.09 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 29 Mar 2009 13:17:10 -0700 (PDT) Message-Id: From: Richard Rak To: users@openjpa.apache.org In-Reply-To: <148A201F-1A0E-4A7B-B62A-35A5F3BE80C0@gmail.com> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v930.3) Subject: Re: IndexOutOfBoundsException in OpenJPA 1.2.1 on Oracle Date: Sun, 29 Mar 2009 16:17:07 -0400 References: <2C051885-B0DB-4913-9E19-700CF25291C7@gmail.com> <198183.82359.qm@web55908.mail.re3.yahoo.com> <72c1350f0903241212k65f07387p774f95a7b0a10b6c@mail.gmail.com> <8F545B75-165D-41C4-8AC2-7C0EE227AE29@gmail.com> <72c1350f0903250754l8ca7791w12c10edfd34f23e8@mail.gmail.com> <4727EE6F-D2F7-4907-980C-98581DC10F43@gmail.com> <72c1350f0903251117h8af5909p710e74a3e49ee117@mail.gmail.com> <8D5C61B5-E06F-488E-B5DB-F745D0267012@gmail.com> <89c0c52c0903251249l41339c70s8223258176d1eb52@mail.gmail.com> <1238030079608-2535934.post@n2.nabble.com> <72c1350f0903260734j2a341595l456e0bad1677c02b@mail.gmail.com> <148A201F-1A0E-4A7B-B62A-35A5F3BE80C0@gmail.com> X-Mailer: Apple Mail (2.930.3) X-Virus-Checked: Checked by ClamAV on apache.org Hello all, I've created the following JIRA and attached a test case that triggers the bug: https://issues.apache.org/jira/browse/OPENJPA-1001 Regards, Richard Rak On 26-Mar-09, at 3:28 PM, Richard Rak wrote: > I've done some more digging around, and it appears that the cause of > the bug is actually a joined table entry: > > @Table(name = "CUSTOMER") > public class Customer implements Serializable { > @EmbeddedId > protected CustomerPK customerPK; > @JoinColumns({@JoinColumn(name = "DEFAULT_DISCOUNT", > referencedColumnName = "DISCOUNT_NAME"), @JoinColumn(name = > "CLIENT_ID", referencedColumnName = "CLIENT_ID")}) > @ManyToOne(fetch = FetchType.LAZY) > private DiscountProfile discountProfile; > ... > } > > @Embeddable > public class CustomerPK implements Serializable { > @Column(name = "CUSTOMER_ID", nullable = false, precision = 9) > private int customerId; > @Column(name = "CLIENT_ID", nullable = false, length = 35) > private String clientId; > > ... > } > > Without fetch=LAZY, I hit the same IndexOutOfBoundsException. Now, > however, I am hitting the exception when I am accessing that field > (I am getting the exception in the if statement as per below): > > Customer c = <...>; > String disc = null; > > if (c.getDiscountProfile() != null) { > disc = c.getDiscountProfile() > .getDiscountProfilePK() > .getDiscountName(); > } > > And here is the exception: > > Caused by: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1 > at java.util.ArrayList.RangeCheck(ArrayList.java:547) > at java.util.ArrayList.get(ArrayList.java:322) > at > org.apache.openjpa.jdbc.sql.SQLBuffer.setParameters(SQLBuffer.java: > 615) > at > org > .apache.openjpa.jdbc.sql.SQLBuffer.prepareStatement(SQLBuffer.java: > 515) > at > org > .apache.openjpa.jdbc.sql.SQLBuffer.prepareStatement(SQLBuffer.java: > 471) > at > org > .apache.openjpa.jdbc.sql.SelectImpl.prepareStatement(SelectImpl.java: > 463) > at org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java: > 379) at > org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java:325) > at > org > .apache > .openjpa > .jdbc > .kernel > .JDBCStoreManager.getInitializeStateResult(JDBCStoreManager.java:503) > at > org > .apache > .openjpa > .jdbc.kernel.JDBCStoreManager.initializeState(JDBCStoreManager.java: > 322) > at > org > .apache > .openjpa > .jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:278) > at > org > .apache > .openjpa > .kernel > .DelegatingStoreManager.initialize(DelegatingStoreManager.java:111) > at > org > .apache > .openjpa > .datacache > .DataCacheStoreManager.initialize(DataCacheStoreManager.java:352) > at > org > .apache > .openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreMana > ger.java:111) > at > org > .apache > .openjpa.kernel.ROPStoreManager.initialize(ROPStoreManager.java:57) > at > org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:894) > at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java: > 852) ... 88 more > > > And the root cause: > > DEBUG - Cache miss while looking up key > "com.onehosp.entity.common.DiscountProfile- > com.onehosp.entity.DiscountProfilePK[discountName=null, > clientId=00000-00000-00000-00000-00000-00000]". > 2009-03-26 14:50:21,511 - DEBUG - SQL Cache missed with key: > com.onehosp.entity.common.DiscountProfile in class > org.apache.openjpa.jdbc.kernel.JDBCStoreManager > > If discountName=null, then there is no foreign object to lookup, as > per the DiscountProfile entity class: > > @Entity > @Table(name = "DISCOUNT_PROFILE") > public class DiscountProfile implements Serializable { > @EmbeddedId > protected DiscountProfilePK discountProfilePK; > ... > } > > @Embeddable > public class DiscountProfilePK implements Serializable { > @Column(name = "DISCOUNT_NAME", nullable = false, length = 120) > private String discountName; > @Column(name = "CLIENT_ID", nullable = false, length = 35) > private String clientId; > ... > } > > Because "DISCOUNT_NAME" is set "nullable = false" in the primary > key, a foreign key relationship only exists in Customer if a > "DEFAULT_DISCOUNT" and "CLIENT_ID" are both set to non-null values. > > Does this make sense? Should the entity manager not realize that > there is no joined table to lookup because there is an incomplete > relationship? > > If I can provide any more information, just ask. > > Regards, and thanks for the continued help, > > > > > > > Richard Rak > richard.rak@gmail.com > > > > On 26-Mar-09, at 10:34 AM, Michael Dick wrote: > >> As I recall that's a rather large change. I'd feel a bit >> uncomfortable >> putting it into a maintenance release (1.2.2). 1.3.x is fair game >> though (if >> it isn't there already). >> >> Seeing as Richard is already having problems with 2.0.0-SNAPSHOT we >> might >> not be out of the woods yet. I'm still a little concerned that >> we're missing >> something, since I can't reproduce the problem on 1.2.1.. >> >> -mike >> >> On Wed, Mar 25, 2009 at 8:14 PM, Pinaki Poddar >> wrote: >> >>> >>> consider backporting Prepare Query Cache to 1.2.x or grin and bear >>> the bugs >>> :) >>> >>> >>> Dang! :-) Sounds like another JIRA issue is required... >>> >>> On Wed, Mar 25, 2009 at 2:15 PM, Richard Rak >>> wrote: >>> >>>> Setting openjpa.jdbc.QuerySQLCache=false makes the bug disappear. >>>> >>>> >>>> Richard Rak >>>> richard.rak@gmail.com >>>> >>>> >>>> >>>> On 25-Mar-09, at 2:17 PM, Michael Dick wrote: >>>> >>>> That wasn't the missing link for me at least. I don't see the >>>> problem >>> with >>>>> the attached files. Did you try disabling the querySQLCache like >>>>> Fay >>>>> mentioned? Might be a good data point for what's going wrong. >>>>> >>>>> -mike >>>>> >>>>> >>>>> On Wed, Mar 25, 2009 at 10:28 AM, Richard Rak >>>> > >>>>> wrote: >>>>> Hello Michael, >>>>> >>>>> Can try using an @EmbeddedId in the customer table? Here is my >>>>> entity: >>>>> >>>>> @Embeddable >>>>> public class CustomerPK implements Serializable { >>>>> >>>>> private static final long serialVersionUID = 1L; >>>>> >>>>> @Column(name = "CUSTOMER_ID", nullable = false, precision = 9) >>>>> private int customerId; >>>>> @Column(name = "CLIENT_ID", nullable = false, length = 35) >>>>> private String clientId; >>>>> >>>>> ... >>>>> >>>>> } >>>>> >>>>> And the relevant entry in Customer: >>>>> >>>>> >>>>> @DiscriminatorColumn >>>>> (name >>>>> ="CUST_TYPE",discriminatorType=DiscriminatorType.STRING,length=1) >>>>> @Entity >>>>> @Inheritance(strategy=InheritanceType.JOINED) >>>>> @Table(name = "CUSTOMER") >>>>> public class Customer implements Serializable { >>>>> private static final long serialVersionUID = 1L; >>>>> @EmbeddedId >>>>> protected CustomerPK customerPK; >>>>> >>>>> ... >>>>> >>>>> } >>>>> >>>>> Maybe that will trigger the bug. I am trying to get the nightly >>>>> builds >>>>> working, but I am getting the following exception: >>>>> >>>>> java.lang.NoSuchMethodError: >>> javax.persistence.OneToMany.orphanRemoval()Z >>>>> at >>>>> >>> org >>> .apache >>> .openjpa >>> .persistence >>> .AnnotationPersistenceMetaDataParser >>> .parseOneToMany(AnnotationPersistenceMetaDataParser.java:1423) >>>>> at >>>>> >>> org >>> .apache >>> .openjpa >>> .persistence >>> .AnnotationPersistenceMetaDataParser >>> .parseMemberAnnotations(AnnotationPersistenceMetaDataParser.java: >>> 1058) >>>>> at >>>>> >>> org >>> .apache >>> .openjpa >>> .persistence >>> .AnnotationPersistenceMetaDataParser >>> .parseClassAnnotations(AnnotationPersistenceMetaDataParser.java:667) >>>>> at >>>>> >>> org >>> .apache >>> .openjpa >>> .persistence >>> .AnnotationPersistenceMetaDataParser >>> .parse(AnnotationPersistenceMetaDataParser.java:403) >>>>> at >>>>> >>> org >>> .apache >>> .openjpa >>> .persistence >>> .PersistenceMetaDataFactory.load(PersistenceMetaDataFactory.java: >>> 230) >>>>> .... >>>>> >>>>> If I can track down the class loading issue that is causing this >>>>> error, >>>>> I'll post my results with the latest 2.0.0 snapshot. >>>>> >>>>> Thanks for the help, and let me know if I can provide any more >>>>> information. >>>>> >>>>> >>>>> Regards, >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> Richard Rak >>>>> richard.rak@gmail.com >>>>> >>>>> >>>>> >>>>> On 25-Mar-09, at 10:54 AM, Michael Dick wrote: >>>>> >>>>> That's the svn revision from the 1.2.1 tag. So you should have >>>>> the fix. >>> I >>>>> still haven't been able to reproduce the problem though. >>>>> >>>>> I wrote a maven project to try and hit the problem. The entities >>>>> are >>>>> basically what you mentioned in your earlier email (I started >>>>> adding >>> fields >>>>> to try and get the exception). The query is identical to what you >>> posted. >>>>> >>>>> Is there anything obvious that I missed in the app? If the >>>>> attachment is >>>>> dropped by the list I'll post the relevant source in pastebin. >>>>> >>>>> -mike >>>>> >>>>> On Tue, Mar 24, 2009 at 2:23 PM, Richard Rak >>>> > >>>>> wrote: >>>>> It is the 1.2.1 release (I think): >>>>> >>>>> OpenJPA 1.2.1 >>>>> version id: openjpa-1.2.1-r752877:753278 >>>>> Apache svn revision: 752877:753278 >>>>> >>>>> >>>>> >>>>> >>>>> Richard Rak >>>>> richard.rak@gmail.com >>>>> >>>>> >>>>> >>>>> On 24-Mar-09, at 3:12 PM, Michael Dick wrote: >>>>> >>>>> That post resulted in OPENJPA-838 [1], which was fixed in the >>>>> 1.2.1 >>>>> release. >>>>> It was pulled out for about a week though (and eventually put >>>>> back in). >>>>> >>>>> Richard, are you using the official 1.2.1 release, or one of the >>>>> snapshots? >>>>> If it's *the* release then you might have hit a different >>>>> scenario that >>>>> was >>>>> originally reported. If it's a snapshot, post the revision >>>>> number and we >>>>> can >>>>> track down whether you should have had the fix (or just move up >>>>> to the >>>>> release).. >>>>> >>>>> -mike >>>>> >>>>> On Tue, Mar 24, 2009 at 2:09 PM, Fay Wang >>>>> wrote: >>>>> >>>>> >>>>> I could not reproduce your problem in OpenJPA 1.2.x. What >>>>> revision are >>> you >>>>> using? From the stack trace, you might want to set >>>>> >>>>> to see if it works. >>>>> >>>>> -Fay >>>>> >>>>> >>>>> >>>>> --- On Tue, 3/24/09, Richard Rak wrote: >>>>> >>>>> From: Richard Rak >>>>> Subject: IndexOutOfBoundsException in OpenJPA 1.2.1 on Oracle >>>>> To: users@openjpa.apache.org >>>>> Date: Tuesday, March 24, 2009, 9:52 AM >>>>> Hello all, >>>>> >>>>> I have an application that I have upgraded from OpenJPA 1.1 >>>>> (I could not use 1.2.0, as I was hitting an Oracle >>>>> dictionary bug) to 1.2.1, and now I am getting an >>>>> IndexOutOfBoundsException while executing the following >>>>> code: >>>>> >>>>> s = >>>>> (com.onehosp.entity.common.Staff) >>>>> >>>>> em.createQuery("SELECT s "+ >>>>> >>>>> >>>>> "FROM Staff s "+ >>>>> >>>>> >>>>> "WHERE s.username = >>>>> :username ") >>>>> >>>>> .setParameter("username", username) >>>>> >>>>> .getSingleResult(); >>>>> >>>>> Here is the stack trace: >>>>> >>>>> Caused by: java.lang.IndexOutOfBoundsException: Index: 1, >>>>> Size: 1 >>>>> at >>>>> java.util.ArrayList.RangeCheck(ArrayList.java:547) >>>>> at >>>>> java.util.ArrayList.get(ArrayList.java:322) >>>>> at >>>>> org >>>>> .apache.openjpa.jdbc.sql.SQLBuffer.setParameters(SQLBuffer.java: >>>>> 615) >>>>> at >>>>> >>>>> >>> org >>> .apache.openjpa.jdbc.sql.SQLBuffer.prepareStatement(SQLBuffer.java: >>> 515) >>>>> at >>>>> >>>>> >>> org >>> .apache.openjpa.jdbc.sql.SQLBuffer.prepareStatement(SQLBuffer.java: >>> 471) >>>>> at >>>>> >>>>> >>>>> >>> org >>> .apache >>> .openjpa.jdbc.sql.SelectImpl.prepareStatement(SelectImpl.java:463) >>>>> at >>>>> org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java: >>>>> 379) >>>>> at >>>>> org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java: >>>>> 325) >>>>> at >>>>> >>>>> >>>>> >>> org >>> .apache >>> .openjpa >>> .jdbc >>> .kernel >>> .JDBCStoreManager.getInitializeStateResult(JDBCStoreManager.java: >>> 503) >>>>> at >>>>> >>>>> >>>>> >>> org >>> .apache >>> .openjpa >>> .jdbc >>> .kernel.JDBCStoreManager.initializeState(JDBCStoreManager.java:322) >>>>> at >>>>> >>>>> >>>>> >>> org >>> .apache >>> .openjpa >>> .jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:278) >>>>> at >>>>> >>>>> >>>>> >>> org >>> .apache >>> .openjpa >>> .kernel >>> .DelegatingStoreManager.initialize(DelegatingStoreManager.java:111) >>>>> at >>>>> >>>>> >>>>> >>> org >>> .apache >>> .openjpa >>> .datacache >>> .DataCacheStoreManager.initialize(DataCacheStoreManager.java:352) >>>>> at >>>>> >>>>> >>>>> >>> org >>> .apache >>> .openjpa >>> .kernel >>> .DelegatingStoreManager.initialize(DelegatingStoreManager.java:111) >>>>> at >>>>> >>>>> >>>>> >>> org >>> .apache >>> .openjpa.kernel.ROPStoreManager.initialize(ROPStoreManager.java:57) >>>>> at >>>>> org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java: >>>>> 894) >>>>> at >>>>> org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:852) >>>>> ... 94 more >>>>> >>>>> Here is the staff entity class: >>>>> >>>>> @DiscriminatorValue("S") >>>>> @Entity >>>>> @Table(name = "STAFF") >>>>> public class Staff extends Customer { >>>>> private static final long serialVersionUID = >>>>> 1L; >>>>> @Column(name = "USERNAME", length = 65, >>>>> nullable = false, unique = true) >>>>> private String username; >>>>> ... >>>>> } >>>>> >>>>> And here is the Customer entity: >>>>> >>>>> >>>>> >>>>> >>> @DiscriminatorColumn >>> (name >>> ="CUST_TYPE",discriminatorType=DiscriminatorType.STRING,length=1) >>>>> @Entity >>>>> @Inheritance(strategy=InheritanceType.JOINED) >>>>> @Table(name = "CUSTOMER") >>>>> public class Customer implements Serializable { >>>>> ... >>>>> } >>>>> >>>>> persistence.xml: >>>>> >>>>> >>>>> >>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >>>>> xsi:schemaLocation="http://java.sun.com/xml/ns/persistence >>>>> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"> >>>>> >>>> transaction-type="RESOURCE_LOCAL"> >>>>> >>>>> >>>>> >>>>> >>> org.apache.openjpa.persistence.PersistenceProviderImpl>> provider> >>>>> >>>>> jdbc/ONEunmanaged >>>>> >>>>> false >>>>> >>>>> >>>> name="openjpa.ConnectionRetainMode" value="always"/> >>>>> >>>> value="true(CacheSize=5000)"/> >>>>> >>>> name="openjpa.DynamicDataStructs" value="true"/> >>>>> >>>> value="true(CacheSize=1000)"/> >>>>> >>>> name="openjpa.RemoteCommitProvider" value="sjvm"/> >>>>> >>>> name="openjpa.RuntimeUnenhancedClasses" >>>>> value="unsupported"/> >>>>> >>>>> >>>>> >>>>> >>>>> And here is the oracle dictionary: >>>>> >>>>> INFO - Using dictionary class >>>>> "org.apache.openjpa.jdbc.sql.OracleDictionary" (Oracle >>>>> Oracle Database 11g Release 11.1.0.0.0 - Production ,Oracle >>>>> JDBC driver 11.1.0.6.0-Production+). >>>>> >>>>> If you require anymore information, I'll be glad to provide >>>>> it. >>>>> >>>>> Regards, >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> Richard Rak >>>>> richard.rak@gmail.com >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>> >>>> >>> >>> >>> >>> >>> ----- >>> Pinaki Poddar http://ppoddar.blogspot.com/ >>> >>> http://www.linkedin.com/in/pinakipoddar >>> OpenJPA PMC Member/Committer >>> JPA Expert Group Member >>> -- >>> View this message in context: >>> http://n2.nabble.com/IndexOutOfBoundsException-in-OpenJPA-1.2.1-on-Oracle-tp2527858p2535934.html >>> Sent from the OpenJPA Users mailing list archive at Nabble.com. >>> >>> >