openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Dick" <>
Subject Exception when using java.sql.Date as an id
Date Wed, 07 Feb 2007 20:56:32 GMT

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
    at mikedd.entities.SqlDatePK.pcCopyKeyFieldsFromObjectId (
    at mikedd.entities.SqlDatePK.pcNewInstance(
    at org.apache.openjpa.enhance.PCRegistry.newInstance(
    at org.apache.openjpa.kernel.StateManagerImpl.initialize (
    at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeState(
    at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(
    at org.apache.openjpa.kernel.DelegatingStoreManager.initialize(
    at org.apache.openjpa.kernel.ROPStoreManager.initialize(
    at org.apache.openjpa.kernel.BrokerImpl.initialize (
    at org.apache.openjpa.kernel.BrokerImpl.find(
    at org.apache.openjpa.kernel.BrokerImpl.find(
    at org.apache.openjpa.kernel.DelegatingBroker.find (
    at org.apache.openjpa.persistence.EntityManagerImpl.find(
    at mikedd.tests.TestSqlDateId.testFindAfterClear(
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    at java.lang.reflect.Method.invoke (
    at junit.framework.TestCase.runTest(
    . . .

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

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;

public class SqlDatePK {

    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);


        sql = new SqlDatePK();


        sql = null;
        sql = em.find(SqlDatePK.class, date);

     . . .

Thanks in advance,
-Michael Dick

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message