Here is a scenario that shows odd behaviour, I want to see if it is
expected or
not. The docs are not clear on it
If I have a many to one relationship for objects Store to Store
Type and I
create a new Store and assign it to an existing Store type does this
relationship have to have cascasdeType.persist set when I issue a
merge on the
new Store? I had recently removed this as I thought I did not want
to create a
duplicate Store Type whenever I added a new Store. It seems
OpenJPA throws the
attached exception when I only have CascadeType.Refresh set.
Alternatively, this could just be a poorly worded exception/
documentation
meaning OpenJPA would check for the existence of this Store Type
and not
actually persist it if it exists. The behaviour I am looking for is
simply
persist the relation (i.e. the link field)
Thanks,
Phill
<4|false|0.9.6-incubating>
org.apache.openjpa.persistence.ArgumentException:
Encountered new object
"ca.BidSpec.emall.categories.Category-105603b-508b-9c6-00f4-4031ba6429
e3:0" in
persistent field "ca.BidSpec.emall.stores.Store.type" of managed
object
"[EMAIL PROTECTED]" during attach. However,
this field does
not allow cascade attach. You cannot attach a reference to a new
object without
cascading.
FailedObject:
ca.BidSpec.emall.categories.Category-105603b-508b-9c6-00f4-4031ba6429e
3:0
at
org.apache.openjpa.kernel.AttachStrategy.getReference
(AttachStrategy.java:272)
at
org.apache.openjpa.kernel.AttachStrategy.attachField
(AttachStrategy.java:189)
at
org.apache.openjpa.kernel.VersionAttachStrategy.attach
(VersionAttachStrategy.jav
a:130)
at
org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:236)
at org.apache.openjpa.kernel.AttachManager.attach
(AttachManager.java:97)
at org.apache.openjpa.kernel.BrokerImpl.attach(BrokerImpl.java:3124)
at
org.apache.openjpa.kernel.DelegatingBroker.attach
(DelegatingBroker.java:1120)
at
org.apache.openjpa.persistence.EntityManagerImpl.merge
(EntityManagerImpl.java:59
1)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.jav
a:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.springframework.orm.jpa.ExtendedEntityManagerCreator
$ExtendedEntityManagerIn
vocationHandler.invoke(ExtendedEntityManagerCreator.java:283)
at $Proxy37.merge(Unknown Source)
at
ca.BidSpec.emall.persistence.JPAPersistenceFactory.merge
(JPAPersistenceFactory.j
ava:95)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.jav
a:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflectio
n(AopUtils
.java:304)
at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke
(JdkDynamicAopProxy.j
ava:197)
at $Proxy35.merge(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.jav
a:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflectio
n(AopUtils
.java:304)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoi
npoint(Ref
lectiveMethodInvocation.java:172)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
(ReflectiveM
ethodInvocation.java:139)
at
org.springframework.transaction.interceptor.TransactionInterceptor.inv
oke(Transa
ctionInterceptor.java:107)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
(ReflectiveM
ethodInvocation.java:161)
at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke
(JdkDynamicAopProxy.j
ava:203)
at $Proxy35.merge(Unknown Source)
at
ca.BidSpec.testing.emall.StoreFactoryTest.testSave
(StoreFactoryTest.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.jav
a:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at
org.springframework.test.ConditionalTestCase.runBare
(ConditionalTestCase.java:69
)
at
org.springframework.test.annotation.AbstractAnnotationAwareTransaction
alTests.ac
cess$001(AbstractAnnotationAwareTransactionalTests.java:47)
at
org.springframework.test.annotation.AbstractAnnotationAwareTransaction
alTests$1.
run(AbstractAnnotationAwareTransactionalTests.java:115)
at
org.springframework.test.annotation.AbstractAnnotationAwareTransaction
alTests.ru
nTest(AbstractAnnotationAwareTransactionalTests.java:180)
at
org.springframework.test.annotation.AbstractAnnotationAwareTransaction
alTests.ru
nTestTimed(AbstractAnnotationAwareTransactionalTests.java:153)
at
org.springframework.test.annotation.AbstractAnnotationAwareTransaction
alTests.ru
nBare(AbstractAnnotationAwareTransactionalTests.java:111)
at
org.springframework.test.jpa.AbstractJpaTests.runBare
(AbstractJpaTests.java:159)
at
org.springframework.test.jpa.AbstractJpaTests.runBare
(AbstractJpaTests.java:239)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at
org.junit.internal.runners.OldTestClassRunner.run
(OldTestClassRunner.java:35)
at
org.junit.internal.runners.CompositeRunner.run(CompositeRunner.java:
29)
at
org.junit.internal.runners.TestClassRunner$1.runUnprotected
(TestClassRunner.java
:42)
at
org.junit.internal.runners.BeforeAndAfterRunner.runProtected
(BeforeAndAfterRunne
r.java:34)
at
org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:
52)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run
(JUnit4TestReferen
ce.java:38)
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.jav
a:196)