Hello everyone:
i configured two entity,mapped with oneToMany and manyToOne。 and i want
merge one enity and the
another entity could cascade merge. but it didn't work. an exception
occured. i can't confirm this exception whether reasonable!
@Entity
@Table(name="point_appcard")
public class PointAppCardEntity {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private long appid;
private Date created = Calendar.getInstance().getTime();
private Date modified = Calendar.getInstance().getTime();
@OneToMany(mappedBy="appCard",fetch=FetchType.EAGER,cascade=CascadeType.MERGE)
private List<PointCardEntity> cards;
}
@Entity
@Table(name="point_card")
public class PointCardEntity {
@Id
private String cardno;
private Date created = Calendar.getInstance().getTime();
private Date modified = Calendar.getInstance().getTime();
@ManyToOne(fetch=FetchType.EAGER,cascade={CascadeType.MERGE})
@JoinTable(name="point_carddetail",
joinColumns=@JoinColumn(name="cardno",
referencedColumnName="cardno"),
inverseJoinColumns=@JoinColumn(name="appid",
referencedColumnName="appid"))
}
and the full stack trace is:
<openjpa-2.2.1-runknown nonfatal store error>
org.apache.openjpa.util.StoreException:
org.apache.openjpa.util.java$util$Date$proxy cannot be cast to
org.apache.openjpa.enhance.PersistenceCapable
at
org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:2000)
at org.apache.openjpa.kernel.LocalManagedRuntime.commit
(LocalManagedRuntime.java:81)
at org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1516)
at
org.apache.openjpa.kernel.DelegatingBroker.commit(DelegatingBroker.java:933)
at org.apache.openjpa.persistence.EntityManagerImpl.commit
(EntityManagerImpl.java:570)
at
com.shangquan.test.pm.dao.TestPointAppCardDao.TestUpdatePointAppCardWithPointCard
(TestPointAppCardDao.java:201)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
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.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:
org.apache.openjpa.util.java$util$Date$proxy
cannot be cast to org.apache.openjpa.enhance.PersistenceCapable
at org.apache.openjpa.jdbc.meta.strats.RelationFieldStrategy.update
(RelationFieldStrategy.java:374)
at
org.apache.openjpa.jdbc.meta.FieldMapping.update(FieldMapping.java:699)
at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.update
(AbstractUpdateManager.java:343)
at
org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.populateRowManager
(AbstractUpdateManager.java:174)
at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush
(AbstractUpdateManager.java:97)
at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush
(AbstractUpdateManager.java:78)
at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:735)
at org.apache.openjpa.kernel.DelegatingStoreManager.flush
(DelegatingStoreManager.java:131)
at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2176)
at
org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:2074)
at
org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1992)
... 21 more
if anyone has encountered this exception before,any solutions avaliable?
thanks very much
--
View this message in context: http://openjpa.208410.n2.nabble.com/openjpa-2-2-1-when-i-cascade-merge-entity-a-exception-thrown-tp7584325.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.
|