openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adrian Co <...@exist.com>
Subject Problem using embedded entities with field access
Date Fri, 18 Jan 2008 01:59:00 GMT
Hi,

Sorry for the long email on this one.

I declared an embeddable entity:

@Embeddable
public class OwnerInfo implements Serializable {

    @Enumerated(EnumType.STRING)
    protected OwnerScope scope;
    .....
}

and used it in a another entity:

@MappedSuperclass
public abstract class AbstractModel implements  Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    protected Long id;

    @Version
    protected Integer optLock;

    ....
}

@Entity
@Table(name = "question")
public class QuestionModel extends AbstractModel {

    @Embedded
    protected OwnerInfo ownerInfo = new OwnerInfo();

    ....
}

Everything worked fine when using property access, when I switched to 
using field access (above) I got the following exception:

org.springframework.transaction.UnexpectedRollbackException: JPA 
transaction unexpectedly rolled back (maybe marked rollback-only after a 
failed operation); nested exception is 
<openjpa-1.1.0-SNAPSHOT-r420667:612846M fatal store error> 
org.apache.openjpa.persistence.RollbackException: No state snapshot is 
available for instance of type "com.exist.eot.user.model.ext.OwnerInfo", 
but this instance uses state-comparison for dirty detection.
Caused by: <openjpa-1.1.0-SNAPSHOT-r420667:612846M fatal store error> 
org.apache.openjpa.persistence.RollbackException: No state snapshot is 
available for instance of type "com.exist.eot.user.model.ext.OwnerInfo", 
but this instance uses state-comparison for dirty detection.
    at 
org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:490)
    at 
org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:433)
    at 
org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:662)
    at 
org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:632)
    at 
org.unitils.database.transaction.impl.SpringTransactionManager.commit(SpringTransactionManager.java:105)
    at 
org.unitils.database.DatabaseModule.endTransaction(DatabaseModule.java:303)
    at 
org.unitils.database.DatabaseModule$DatabaseTestListener.afterTestTearDown(DatabaseModule.java:391)
    at 
org.unitils.core.Unitils$UnitilsTestListener.afterTestTearDown(Unitils.java:270)
    at 
org.unitils.UnitilsJUnit4TestClassRunner$CustomTestClassMethodsRunner.invokeTestMethod(UnitilsJUnit4TestClassRunner.java:165)
    at 
org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
    at 
org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
    at 
org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
    at 
org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
    at 
org.unitils.UnitilsJUnit4TestClassRunner.run(UnitilsJUnit4TestClassRunner.java:95)
    at 
org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
    at 
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:138)
    at 
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:125)
    at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
    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 
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:290)
    at 
org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:818)
Caused by: <openjpa-1.1.0-SNAPSHOT-r420667:612846M fatal general error> 
org.apache.openjpa.persistence.PersistenceException: No state snapshot 
is available for instance of type 
"com.exist.eot.user.model.ext.OwnerInfo", but this instance uses 
state-comparison for dirty detection.
    at 
org.apache.openjpa.kernel.StateManagerImpl.dirtyCheck(StateManagerImpl.java:815)
    at 
org.apache.openjpa.kernel.ManagedCache.dirtyCheck(ManagedCache.java:307)
    at 
org.apache.openjpa.kernel.BrokerImpl.hasTransactionalObjects(BrokerImpl.java:3774)
    at org.apache.openjpa.kernel.BrokerImpl.setDirty(BrokerImpl.java:3891)
    at 
org.apache.openjpa.kernel.StateManagerImpl.setPCState(StateManagerImpl.java:220)
    at 
org.apache.openjpa.kernel.StateManagerImpl.dirty(StateManagerImpl.java:1557)
    at 
org.apache.openjpa.kernel.StateManagerImpl.dirty(StateManagerImpl.java:1497)
    at 
org.apache.openjpa.kernel.StateManagerImpl.dirtyCheck(StateManagerImpl.java:825)
    at 
org.apache.openjpa.kernel.ManagedCache.dirtyCheck(ManagedCache.java:307)
    at 
org.apache.openjpa.kernel.BrokerImpl.hasTransactionalObjects(BrokerImpl.java:3774)
    at 
org.apache.openjpa.kernel.BrokerImpl.getTransactionalStates(BrokerImpl.java:3763)
    at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1909)
    at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1890)
    at 
org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1808)
    at 
org.apache.openjpa.kernel.LocalManagedRuntime.commit(LocalManagedRuntime.java:81)
    at org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1332)
    at 
org.apache.openjpa.kernel.DelegatingBroker.commit(DelegatingBroker.java:861)
    at 
org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:479)
    ... 23 more

Could anyone tell me what I'm doing wrong? Let me know if anyone needs 
more details.

Thanks in advance.

Regards,
Adrian Co

PS: When I added an @Id field to the OwnerInfo class, the exception 
disappeared. I don't know why and I don't think its the right fix. :)

Mime
View raw message