Return-Path: Delivered-To: apmail-incubator-open-jpa-dev-archive@locus.apache.org Received: (qmail 58331 invoked from network); 7 Feb 2007 22:34:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 7 Feb 2007 22:34:28 -0000 Received: (qmail 89355 invoked by uid 500); 7 Feb 2007 22:34:35 -0000 Delivered-To: apmail-incubator-open-jpa-dev-archive@incubator.apache.org Received: (qmail 89330 invoked by uid 500); 7 Feb 2007 22:34:34 -0000 Mailing-List: contact open-jpa-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: open-jpa-dev@incubator.apache.org Delivered-To: mailing list open-jpa-dev@incubator.apache.org Received: (qmail 89320 invoked by uid 99); 7 Feb 2007 22:34:34 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Feb 2007 14:34:34 -0800 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of michael.d.dick@gmail.com designates 64.233.182.190 as permitted sender) Received: from [64.233.182.190] (HELO nf-out-0910.google.com) (64.233.182.190) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Feb 2007 14:34:25 -0800 Received: by nf-out-0910.google.com with SMTP id d4so644212nfe for ; Wed, 07 Feb 2007 14:34:03 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=mMyfeeMkFAeIlGhpkUr50XO6jFyvipyNe3Yttr0UuaLqfZ9YW50TcOLBTuUMdc62tPndJ2m3LznLgFI755pBu2Wm+j4Zo+c4UuuCXEKgYty9go13FfjiYnKU255rn5uSxuY++AVPwKQHfiQts9acx1lv7k4H9Aq8N24D/j6KTNw= Received: by 10.82.111.8 with SMTP id j8mr740171buc.1170887636700; Wed, 07 Feb 2007 14:33:56 -0800 (PST) Received: by 10.82.134.14 with HTTP; Wed, 7 Feb 2007 14:33:56 -0800 (PST) Message-ID: <72c1350f0702071433n3ecc5a1co665e3ae7b4843001@mail.gmail.com> Date: Wed, 7 Feb 2007 16:33:56 -0600 From: "Michael Dick" To: open-jpa-dev@incubator.apache.org Subject: Re: Exception when using java.sql.Date as an id In-Reply-To: <65ADD18F-1311-45FB-8784-5A3364061D3A@SUN.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_15941_23428747.1170887636283" References: <72c1350f0702071256l3840851diae3d0661eb7adc6f@mail.gmail.com> <7D856CDFE035FF45A0420ACBD71BDD6303280481@repbex02.amer.bea.com> <65ADD18F-1311-45FB-8784-5A3364061D3A@SUN.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_15941_23428747.1170887636283 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Thanks, I'll open a JIRA report and take a crack at a solution. On 2/7/07, Craig L Russell wrote: > > > On Feb 7, 2007, at 1:55 PM, Patrick Linskey wrote: > > >> It's coming from the generated bytecode which expects there > >> to be a getId > >> method that returns the same type of the Id, however > >> java.sql.Date is using > >> the same ID class as java.util.Date. Do we need a separate class for > >> java.sql.Date ? > > > > It looks like we either need a separate type for java.sql.Date (and > > presumably java.sql.Timestamp), or we need to change the logic to > > accept > > a getId() method that returns a type that is assignable from the id > > field's type. > > It's probably cleaner if we have separate classes for the different > types. That is, have the getId method in the new > org.apache.openjpa.util.SQLDateId return the proper type > (java.sql.Date). After all, java.sql.{Date, Time, Timestamp} are not > really the same as java.util.Date. > > Craig > > > > -Patrick > > > > -- > > Patrick Linskey > > BEA Systems, Inc. > > > > ______________________________________________________________________ > > _ > > Notice: This email message, together with any attachments, may > > contain > > information of BEA Systems, Inc., its subsidiaries and > > affiliated > > entities, that may be confidential, proprietary, copyrighted > > and/or > > legally privileged, and is intended solely for the use of the > > individual > > or entity named in this message. If you are not the intended > > recipient, > > and have received this message in error, please immediately return > > this > > by email and then delete it. > > > >> -----Original Message----- > >> From: Michael Dick [mailto: michael.d.dick@gmail.com] > >> Sent: Wednesday, February 07, 2007 12:57 PM > >> To: open-jpa-dev@incubator.apache.org > >> Subject: Exception when using java.sql.Date as an id > >> > >> Hi, > >> > >> I'm getting the following exception when I try to fetch an > >> entity with a > >> java.sql.Date as the id : > >> > >> java.lang.NoSuchMethodError: org.apache.openjpa.util.DateId.getId > >> ()Ljava/sql/Date; > >> at mikedd.entities.SqlDatePK.pcCopyKeyFieldsFromObjectId > >> (SqlDatePK.java > >> ) > >> at mikedd.entities.SqlDatePK.pcNewInstance(SqlDatePK.java) > >> at > >> org.apache.openjpa.enhance.PCRegistry.newInstance(PCRegistry.java > >> :118) > >> at org.apache.openjpa.kernel.StateManagerImpl.initialize ( > >> StateManagerImpl.java:247) > >> at > >> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeState( > >> JDBCStoreManager.java:327) > >> at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize( > >> JDBCStoreManager.java:252) > >> at org.apache.openjpa.kernel.DelegatingStoreManager.initialize ( > >> DelegatingStoreManager.java:108) > >> at org.apache.openjpa.kernel.ROPStoreManager.initialize( > >> ROPStoreManager.java:54) > >> at org.apache.openjpa.kernel.BrokerImpl.initialize > >> (BrokerImpl.java:868) > >> at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:826) > >> at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:743) > >> at org.apache.openjpa.kernel.DelegatingBroker.find ( > >> DelegatingBroker.java:169) > >> at org.apache.openjpa.persistence.EntityManagerImpl.find( > >> EntityManagerImpl.java:346) > >> at > >> mikedd.tests.TestSqlDateId.testFindAfterClear (TestSqlDateId.java:25) > >> at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) > >> at sun.reflect.NativeMethodAccessorImpl.invoke( > >> NativeMethodAccessorImpl.java:39) > >> at sun.reflect.DelegatingMethodAccessorImpl.invoke( > >> DelegatingMethodAccessorImpl.java:25) > >> at java.lang.reflect.Method.invoke (Method.java:585) > >> at junit.framework.TestCase.runTest(TestCase.java :154) > >> . . . > >> > >> It's coming from the generated bytecode which expects there > >> to be a getId > >> method that returns the same type of the Id, however > >> java.sql.Date is using > >> the same ID class as java.util.Date. Do we need a separate class for > >> java.sql.Date? > >> > >> Here's the entity and testcase that I'm running (in case I > >> missed something > >> along the way) > >> > >> Entity : > >> import java.sql.Date; > >> > >> import javax.persistence.Entity; > >> import javax.persistence.Id ; > >> > >> @Entity > >> public class SqlDatePK { > >> > >> @Id > >> private Date id; > >> private String name; > >> > >> . . . > >> } > >> > >> Testcase : > >> public void testFindAfterClear() { > >> SqlDatePK sql; > >> > >> EntityManager em = _emf.createEntityManager(); > >> > >> long ms = 101010; // arbitrary date. > >> java.sql.Date date = new java.sql.Date(ms); > >> > >> em.getTransaction().begin(); > >> > >> sql = new SqlDatePK(); > >> sql.setId(date); > >> em.persist(sql); > >> > >> em.getTransaction().commit(); > >> > >> em.clear(); > >> sql = null; > >> sql = em.find(SqlDatePK.class , date); > >> > >> . . . > >> } > >> > >> Thanks in advance, > >> -- > >> -Michael Dick > >> > > Craig Russell > Architect, Sun Java Enterprise System http://java.sun.com/products/jdo > 408 276-5638 mailto:Craig.Russell@sun.com > P.S. A good JDO? O, Gasp! > > > -- -Michael Dick ------=_Part_15941_23428747.1170887636283--