Hi,
After upgrade from EclipseLink M3 to M6 we
a problem with OneToOne relationships using interfaces and target entity. I
have created a small dummy example which causes the error (at deploy time) and
attached the corresponding error trace. Please let
me know if you need me to provide more
information.
Hope someone are able to tell me what is
wrong or if a workaround exists.
Best regards,
Rune
-------------------------------
public interface TestInterface
{
}
--------------------------------
@Entity
public class TestRelation implements
TestInterface {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long
id;
}
--------------------------------
@Entity
public class TestEntity
{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long
id;
@OneToOne(cascade =
CascadeType.ALL, targetEntity = TestRelation.class)
@JoinColumn(name =
"test1_id")
private TestInterface
test1;
@OneToOne(cascade =
CascadeType.ALL, targetEntity = TestRelation.class)
@JoinColumn(name =
"test2_id")
private TestInterface
test2;
}
------------------------------------------------------------------------------
Error trace:
org.springframework.transaction.CannotCreateTransactionException:
Could not open JPA EntityManager for transaction; nested exception is
javax.persistence.PersistenceException: Exception [EclipseLink-0] (Eclipse
Persistence Services - 1.0 (Build SNAPSHOT - 20080409)):
org.eclipse.persistence.exceptions.IntegrityException
Descriptor Exceptions:
---------------------------------------------------------
Exception [EclipseLink-48] (Eclipse
Persistence Services - 1.0 (Build SNAPSHOT - 20080409)):
org.eclipse.persistence.exceptions.DescriptorException
Exception Description:
Multiple writable mappings exist for the field [TESTENTITY.DTYPE]. Only
one may be defined as writable, all others must be specified
read-only.
Mapping:
org.eclipse.persistence.mappings.VariableOneToOneMapping[test2]
Descriptor:
RelationalDescriptor(com.statoil.domain.TestEntity -->
[DatabaseTable(TESTENTITY)])
Runtime Exceptions:
---------------------------------------------------------
at
org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:375)
at
org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:377)
at
org.springframework.test.AbstractTransactionalSpringContextTests.startNewTransaction(AbstractTransactionalSpringContextTests.java:387)
at
org.springframework.test.AbstractTransactionalSpringContextTests.onSetUp(AbstractTransactionalSpringContextTests.java:217)
at
org.springframework.test.AbstractSingleSpringContextTests.setUp(AbstractSingleSpringContextTests.java:103)
at junit.framework.TestCase.runBare(TestCase.java:125)
at
org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:76)
at
org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.access$001(AbstractAnnotationAwareTransactionalTests.java:71)
at
org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests$1.run(AbstractAnnotationAwareTransactionalTests.java:175)
at
org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.runTest(AbstractAnnotationAwareTransactionalTests.java:283)
at
org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.runTestTimed(AbstractAnnotationAwareTransactionalTests.java:254)
at
org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.runBare(AbstractAnnotationAwareTransactionalTests.java:172)
at
org.springframework.test.jpa.AbstractJpaTests.runBare(AbstractJpaTests.java:174)
at
org.springframework.test.jpa.AbstractJpaTests.runBare(AbstractJpaTests.java:255)
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)
Caused by:
javax.persistence.PersistenceException: Exception [EclipseLink-0] (Eclipse
Persistence Services - 1.0 (Build SNAPSHOT - 20080409)):
org.eclipse.persistence.exceptions.IntegrityException
Descriptor Exceptions:
---------------------------------------------------------
Exception [EclipseLink-48] (Eclipse
Persistence Services - 1.0 (Build SNAPSHOT - 20080409)):
org.eclipse.persistence.exceptions.DescriptorException
Exception Description: Multiple writable
mappings exist for the field [TESTENTITY.DTYPE]. Only one may be defined
as writable, all others must be specified read-only.
Mapping:
org.eclipse.persistence.mappings.VariableOneToOneMapping[test2]
Descriptor:
RelationalDescriptor(com.statoil.domain.TestEntity -->
[DatabaseTable(TESTENTITY)])
Runtime Exceptions:
---------------------------------------------------------
at
org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:255)
at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:69)
at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:118)
at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:112)
at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:100)
at
org.springframework.orm.jpa.JpaTransactionManager.createEntityManagerForTransaction(JpaTransactionManager.java:392)
at
org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:320)
... 25 more
Caused by: Exception [EclipseLink-0]
(Eclipse Persistence Services - 1.0 (Build SNAPSHOT - 20080409)):
org.eclipse.persistence.exceptions.IntegrityException
Descriptor Exceptions:
---------------------------------------------------------
Exception [EclipseLink-48] (Eclipse
Persistence Services - 1.0 (Build SNAPSHOT - 20080409)):
org.eclipse.persistence.exceptions.DescriptorException
Exception Description: Multiple writable
mappings exist for the field [TESTENTITY.DTYPE]. Only one may be defined
as writable, all others must be specified read-only.
Mapping:
org.eclipse.persistence.mappings.VariableOneToOneMapping[test2]
Descriptor:
RelationalDescriptor(com.statoil.domain.TestEntity -->
[DatabaseTable(TESTENTITY)])
Runtime Exceptions:
---------------------------------------------------------
at
org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:472)
at
org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:404)
at
org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:649)
at
org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login(DatabaseSessionImpl.java:615)
at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:216)
at
org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:234)
... 31 more