openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Albert Lee (JIRA)" <j...@apache.org>
Subject [jira] [Created] (OPENJPA-2359) Output warning of ClassCastException when multiple entities share the same db table but with inconsistency field definitions
Date Wed, 27 Mar 2013 14:07:40 GMT
Albert Lee created OPENJPA-2359:
-----------------------------------

             Summary: Output warning of ClassCastException when multiple entities share the
same db table but with inconsistency field definitions
                 Key: OPENJPA-2359
                 URL: https://issues.apache.org/jira/browse/OPENJPA-2359
             Project: OpenJPA
          Issue Type: Improvement
          Components: jpa
    Affects Versions: 2.2.1, 2.1.1, 2.0.1, 2.3.0, 2.2.1.1
            Reporter: Albert Lee
            Priority: Minor


A ClassCastException similar to the following is thrown when multiple entities share the same
db table but with inconsistency field definitions.

<openjpa-2.0.2-SNAPSHOT-r422266:1392660 nonfatal general error> org.apache.openjpa.persistence.PersistenceException:
java.lang.String incompatible with java.util.Date
FailedObject: 1 [org.apache.openjpa.util.StringId] [java.lang.String]
	at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:989)
	at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:883)
	at org.apache.openjpa.kernel.DelegatingBroker.find(DelegatingBroker.java:223)
	at org.apache.openjpa.persistence.EntityManagerImpl.find(EntityManagerImpl.java:477)
	at org.apache.openjpa.persistence.query.TestPMRDateString.testSimple(TestPMRDateString.java:60)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
	at java.lang.reflect.Method.invoke(Method.java:611)
	at junit.framework.TestCase.runTest(TestCase.java:154)
	at org.apache.openjpa.persistence.test.AbstractPersistenceTestCase.runTest(AbstractPersistenceTestCase.java:516)
	at junit.framework.TestCase.runBare(TestCase.java:127)
	at org.apache.openjpa.persistence.test.AbstractPersistenceTestCase.runBare(AbstractPersistenceTestCase.java:503)
	at org.apache.openjpa.persistence.test.AbstractPersistenceTestCase.runBare(AbstractPersistenceTestCase.java:479)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:118)
	at org.apache.openjpa.persistence.test.AbstractPersistenceTestCase.run(AbstractPersistenceTestCase.java:179)
	at junit.framework.TestSuite.runTest(TestSuite.java:208)
	at junit.framework.TestSuite.run(TestSuite.java:203)
	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassCastException: java.lang.String incompatible with java.util.Date
	at org.apache.openjpa.kernel.SingleFieldManager.proxy(SingleFieldManager.java:107)
	at org.apache.openjpa.kernel.StateManagerImpl.storeObjectField(StateManagerImpl.java:2607)
	at org.apache.openjpa.kernel.StateManagerImpl.storeField(StateManagerImpl.java:2707)
	at org.apache.openjpa.kernel.StateManagerImpl.storeField(StateManagerImpl.java:882)
	at org.apache.openjpa.kernel.StateManagerImpl.store(StateManagerImpl.java:878)
	at org.apache.openjpa.jdbc.meta.strats.HandlerFieldStrategy.load(HandlerFieldStrategy.java:199)
	at org.apache.openjpa.jdbc.meta.FieldMapping.load(FieldMapping.java:928)
	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1112)
	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1056)
	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeState(JDBCStoreManager.java:427)
	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:322)
	at org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:112)
	at org.apache.openjpa.kernel.ROPStoreManager.initialize(ROPStoreManager.java:57)
	at org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:1008)
	at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:966)
	... 26 more

See the attached test case's entities field definitions:

    @Temporal(TemporalType.DATE)
    @Column(name = "EFF_FROM_DT")
    private Date effFromDt;


    // @Temporal(TemporalType.DATE)
    @Column(name = "EFF_FROM_DT")
    private String effFromDt;

This is an application problem but would be nice for OpenJPA to provide more diagnostic is
this happens so that user can catch the problem and get it fix easier.


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message