Kevin,
I think there is a problem in OpenJPA when you have the @Version annotation
on a class and it is a java.sql.Timestamp object. When you have this
situation, OpenJPA gives you the exception I listed below.
I know that Hibernate recommends against this, but it is a part of the JPA
spec to allow for Timestamp columns to act as @Version objects.
Ron
On Fri, Feb 29, 2008 at 11:38 AM, Kevin Sutter <[EMAIL PROTECTED]> wrote:
> Ron,
>
> On Fri, Feb 29, 2008 at 10:23 AM, Ronald R. DiFrango <
> [EMAIL PROTECTED]> wrote:
>
> > I figured it out, thje @Version column on a Timestamp was not properly
> > processed by the annotation engine.
>
>
> Can you elaborate? Are you indicating that there is a problem in the
> OpenJPA annotation processing? Or, did you figure out a workaround for your
> situation?
>
> Thanks,
> Kevin
>
>
> >
> > On Fri, Feb 29, 2008 at 11:13 AM, Ronald R. DiFrango <
> > [EMAIL PROTECTED]>
> > wrote:
> >
> > > All,
> > >
> > > I am attempting to switch out Hibernate for OpenJPA, but I am getting
> > the
> > > following exception:
> > >
> > >
> > > java.lang.ClassCastException: java.sql.Date
> > > at
> > >
> > com.circuitcity.instantcredit.services.persistance.domain.AccountCarrierTbl.pcReplaceField
> > > (AccountCarrierTbl.java)
> > > at org.apache.openjpa.kernel.StateManagerImpl.replaceField(
> > > StateManagerImpl.java:2990)
> > > at
> > >
> > org.apache.openjpa.kernel.DetachManager$DetachFieldManager.detachVersion
> > (
> > > DetachManager.java:509)
> > > at org.apache.openjpa.kernel.DetachManager.detachInternal(
> > > DetachManager.java:441)
> > > at org.apache.openjpa.kernel.DetachManager.detachAll(
> > > DetachManager.java:310)
> > > at org.apache.openjpa.kernel.BrokerImpl.detachAllInternal(
> > > BrokerImpl.java:3147)
> > > at org.apache.openjpa.kernel.BrokerImpl.free(BrokerImpl.java:4035)
> > > at org.apache.openjpa.kernel.BrokerImpl.close(BrokerImpl.java
> > :4022)
> > > at org.apache.openjpa.kernel.DelegatingBroker.close(
> > > DelegatingBroker.java:1282)
> > > at org.apache.openjpa.persistence.EntityManagerImpl.close(
> > > EntityManagerImpl.java:1002)
> > > at
> > >
> > org.springframework.orm.jpa.JpaTransactionManager.doCleanupAfterCompletion
> > > (JpaTransactionManager.java:514)
> > > at
> > >
> > org.springframework.transaction.support.AbstractPlatformTransactionManager.cleanupAfterCompletion
> > > (AbstractPlatformTransactionManager.java:919)
> > > at
> > >
> > org.springframework.transaction.support.AbstractPlatformTransactionManager.processRollback
> > > (AbstractPlatformTransactionManager.java:785)
> > > at
> > >
> > org.springframework.transaction.support.AbstractPlatformTransactionManager.rollback
> > > (AbstractPlatformTransactionManager.java:730)
> > > at
> > >
> > org.springframework.test.AbstractTransactionalSpringContextTests.endTransaction
> > > (AbstractTransactionalSpringContextTests.java:289)
> > > at
> > >
> > org.springframework.test.AbstractTransactionalSpringContextTests.onTearDown
> > > (AbstractTransactionalSpringContextTests.java:233)
> > > at
> > org.springframework.test.AbstractSingleSpringContextTests.tearDown(
> > > AbstractSingleSpringContextTests.java:125)
> > > at junit.framework.TestCase.runBare(TestCase.java:130)
> > > at org.springframework.test.ConditionalTestCase.runBare(
> > > ConditionalTestCase.java:69)
> > > at
> > >
> > org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.access$001
> > > (AbstractAnnotationAwareTransactionalTests.java:47)
> > > at
> > >
> > org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests$1.run
> > > (AbstractAnnotationAwareTransactionalTests.java:113)
> > > at
> > >
> > org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.runTest
> > > (AbstractAnnotationAwareTransactionalTests.java:176)
> > > at
> > >
> > org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.runTestTimed
> > > (AbstractAnnotationAwareTransactionalTests.java:150)
> > > at
> > >
> > org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.runBare
> > > (AbstractAnnotationAwareTransactionalTests.java:109)
> > > at org.springframework.test.jpa.AbstractJpaTests.runBare(
> > > AbstractJpaTests.java:174)
> > > at org.springframework.test.jpa.AbstractJpaTests.runBare(
> > > AbstractJpaTests.java:254)
> > > 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 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:460)
> > > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests
> > (
> > > RemoteTestRunner.java:673)
> > > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(
> > > RemoteTestRunner.java:386)
> > > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
> > > RemoteTestRunner.java:196)
> > >
> > >
> > > Here is my JPA entity bean definition:
> > >
> > > package com.circuitcity.instantcredit.services.persistance.domain;
> > >
> > > import java.sql.Timestamp;
> > > import java.util.HashSet;
> > > import java.util.Set;
> > >
> > > import javax.persistence.CascadeType;
> > > import javax.persistence.Column;
> > > import javax.persistence.Entity;
> > > import javax.persistence.EntityListeners;
> > > import javax.persistence.FetchType;
> > > import javax.persistence.Id;
> > > import javax.persistence.OneToMany;
> > > import javax.persistence.Table;
> > > import javax.persistence.Version;
> > >
> > > //import org.hibernate.annotations.Cache;
> > > //import org.hibernate.annotations.CacheConcurrencyStrategy;
> > >
> > > import
> > >
> > com.circuitcity.instantcredit.services.persistance.audit.AuditListenter;
> > > import
> > com.circuitcity.instantcredit.services.persistance.audit.Auditable;
> > >
> > > /**
> > > * AcctCrrTbl entity.
> > > *
> > > * @author MyEclipse Persistence Tools
> > > */
> > > @Entity
> > > @Table(name = "acct_crr_tbl", uniqueConstraints = {})
> > > // @Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
> > > @EntityListeners(AuditListenter.class)
> > > @SuppressWarnings("serial")
> > > public class AccountCarrierTbl implements java.io.Serializable,
> > Auditable
> > > {
> > >
> > > // Fields
> > >
> > > private String acctCrrCd;
> > > private String acctCrrNm;
> > > private String actvFlg;
> > > private Integer srtOrdNbr;
> > > private Timestamp crtDttm;
> > > private Timestamp lstUpdDttm;
> > > private String lstUpddByTxt;
> > > private Set<CreditApplicationTbl> crAppTbls = new
> > > HashSet<CreditApplicationTbl>(0);
> > >
> > > // Constructors
> > >
> > > /** default constructor */
> > > public AccountCarrierTbl() {
> > > }
> > >
> > > /** minimal constructor */
> > > public AccountCarrierTbl(String acctCrrCd, Timestamp crtDttm) {
> > > this.acctCrrCd = acctCrrCd;
> > > this.crtDttm = crtDttm;
> > > }
> > >
> > > /** full constructor */
> > > public AccountCarrierTbl(String acctCrrCd, String acctCrrNm,
> > String
> > > actvFlg,
> > > Integer srtOrdNbr, Timestamp crtDttm, Timestamp
> > lstUpdDttm,
> > > String lstUpddByTxt, Set<CreditApplicationTbl> crAppTbls)
> > {
> > > this.acctCrrCd = acctCrrCd;
> > > this.acctCrrNm = acctCrrNm;
> > > this.actvFlg = actvFlg;
> > > this.srtOrdNbr = srtOrdNbr;
> > > this.crtDttm = crtDttm;
> > > this.lstUpdDttm = lstUpdDttm;
> > > this.lstUpddByTxt = lstUpddByTxt;
> > > this.crAppTbls = crAppTbls;
> > > }
> > >
> > > // Property accessors
> > > @Id
> > > @Column(name = "acct_crr_cd", unique = true, nullable = false,
> > > insertable = true, updatable = true, length = 10)
> > > public String getAcctCrrCd() {
> > > return this.acctCrrCd;
> > > }
> > >
> > > public void setAcctCrrCd(String acctCrrCd) {
> > > this.acctCrrCd = acctCrrCd;
> > > }
> > >
> > > @Column(name = "acct_crr_nm", unique = false, nullable = true,
> > > insertable = true, updatable = true, length = 50)
> > > public String getAcctCrrNm() {
> > > return this.acctCrrNm;
> > > }
> > >
> > > public void setAcctCrrNm(String acctCrrNm) {
> > > this.acctCrrNm = acctCrrNm;
> > > }
> > >
> > > @Column(name = "actv_flg", unique = false, nullable = true,
> > insertable
> > > = true, updatable = true, length = 1)
> > > public String getActvFlg() {
> > > return this.actvFlg;
> > > }
> > >
> > > public void setActvFlg(String actvFlg) {
> > > this.actvFlg = actvFlg;
> > > }
> > >
> > > @Column(name = "srt_ord_nbr", unique = false, nullable = true,
> > > insertable = true, updatable = true)
> > > public Integer getSrtOrdNbr() {
> > > return this.srtOrdNbr;
> > > }
> > >
> > > public void setSrtOrdNbr(Integer srtOrdNbr) {
> > > this.srtOrdNbr = srtOrdNbr;
> > > }
> > >
> > > @Column(name = "crt_dttm", unique = false, nullable = false,
> > > insertable = true, updatable = true, length = 4)
> > > public Timestamp getCrtDttm() {
> > > return this.crtDttm;
> > > }
> > >
> > > public void setCrtDttm(Timestamp crtDttm) {
> > > this.crtDttm = crtDttm;
> > > }
> > >
> > > @Version
> > > @Column(name = "lst_upd_dttm", unique = false, nullable = true,
> > > insertable = true, updatable = true, length = 4)
> > > public Timestamp getLstUpdDttm() {
> > > return this.lstUpdDttm;
> > > }
> > >
> > > public void setLstUpdDttm(Timestamp lstUpdDttm) {
> > > this.lstUpdDttm = lstUpdDttm;
> > > }
> > >
> > > @Column(name = "lst_updd_by_txt", unique = false, nullable = true,
> > > insertable = true, updatable = true, length = 100)
> > > public String getLstUpddByTxt() {
> > > return this.lstUpddByTxt;
> > > }
> > >
> > > public void setLstUpddByTxt(String lstUpddByTxt) {
> > > this.lstUpddByTxt = lstUpddByTxt;
> > > }
> > >
> > > @OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY,
> > > mappedBy = "acctCrrTbl")
> > > public Set<CreditApplicationTbl> getCrAppTbls() {
> > > return this.crAppTbls;
> > > }
> > >
> > > public void setCrAppTbls(Set<CreditApplicationTbl> crAppTbls) {
> > > this.crAppTbls = crAppTbls;
> > > }
> > >
> > > }
> > >
> > > Is this a table definition problem? This worked just fine under
> > > Hibernate.
> > >
> > > Ron
> > >
> >
> >
> >
> > --
> > Ron DiFrango
> > Blog (www.captech-soa.blogspot.com)
> >
>
>
--
Ron DiFrango
Blog (www.captech-soa.blogspot.com)