Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [teneo] Exception when using Enums
[teneo] Exception when using Enums [message #58730] Mon, 23 October 2006 08:51 Go to next message
Hans Mueller-Dieckert is currently offline Hans Mueller-DieckertFriend
Messages: 32
Registered: July 2009
Member
This is a multi-part message in MIME format.
--------------090905090207090701020804
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Hi Martin and everybody else reading this !

I have an enum MyEnum in my model and a class which has an attribute
with the type MyEnum. When I have a single object, set the attribute and
save everything in a HibernateResource, everything works fine.

But having two objects, where the attribute for both objects is set to
the same enmu-literal, I get an Exception.

This is the code which does not work:

Resource dbResource = domain.getResourceSet().getResource(uri, true);


TestClass element1 = TestmodelFactory.eINSTANCE.createTestClass();
element1.setEnumProperty(TestEnum.ITEM1_LITERAL);
dbResource.getContents().add(element1);

TestClass element2 = TestmodelFactory.eINSTANCE.createTestClass();
element2.setEnumProperty(TestEnum.ITEM1_LITERAL);
dbResource.getContents().add(element2);

dbResource.save(null);


I'll also attach a little screenshot describing the model and the
exception stack trace.

greetings,
Hans

--------------090905090207090701020804
Content-Type: text/plain;
name="exception.log"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="exception.log"

org.eclipse.emf.teneo.hibernate.HbStoreException: Exception when saving resource test
at org.eclipse.emf.teneo.hibernate.resource.HibernateResource.s aveResource(HibernateResource.java:214)
at org.eclipse.emf.teneo.resource.StoreResource.save(StoreResou rce.java:271)
at de.arcsolutions.remarc.platform.emftest.TwoResourcesLinkTest Case.testTwoResources(TwoResourcesLinkTestCase.java:77)
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 junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestRefer ence.run(JUnit3TestReference.java:128)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(Test Execution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunne r.main(RemotePluginTestRunner.java:58)
at org.eclipse.pde.internal.junit.runtime.CoreTestApplication.r un(CoreTestApplication.java:24)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:78)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:92)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:68)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:400)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:177)
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 org.eclipse.core.launcher.Main.invokeFramework(Main.java:336 )
at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.Main.main(Main.java:952)
Caused by: org.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions
at org.hibernate.collection.AbstractPersistentCollection.setCur rentSession(AbstractPersistentCollection.java:410)
at org.hibernate.event.def.OnUpdateVisitor.processCollection(On UpdateVisitor.java:40)
at org.hibernate.event.def.AbstractVisitor.processValue(Abstrac tVisitor.java:101)
at org.hibernate.event.def.AbstractVisitor.processValue(Abstrac tVisitor.java:61)
at org.hibernate.event.def.AbstractVisitor.processEntityPropert yValues(AbstractVisitor.java:55)
at org.hibernate.event.def.AbstractVisitor.process(AbstractVisi tor.java:123)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formUpdate(DefaultSaveOrUpdateEventListener.java:267)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsDetached(DefaultSaveOrUpdateEventListener.java:216)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl. java:502)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :494)
at org.hibernate.engine.CascadingAction$1.cascade(CascadingActi on.java:134)
at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:213)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java :157)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:10 8)
at org.hibernate.engine.Cascade.cascade(Cascade.java:248)
at org.hibernate.engine.Cascade.cascade(Cascade.java:223)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.cas cadeOnUpdate(DefaultSaveOrUpdateEventListener.java:331)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formUpdate(DefaultSaveOrUpdateEventListener.java:303)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsDetached(DefaultSaveOrUpdateEventListener.java:216)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl. java:502)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :494)
at org.hibernate.engine.CascadingAction$1.cascade(CascadingActi on.java:134)
at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:213)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java :157)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:10 8)
at org.hibernate.engine.Cascade.cascade(Cascade.java:248)
at org.hibernate.event.def.AbstractFlushingEventListener.cascad eOnFlush(AbstractFlushingEventListener.java:130)
at org.hibernate.event.def.AbstractFlushingEventListener.prepar eEntityFlushes(AbstractFlushingEventListener.java:121)
at org.hibernate.event.def.AbstractFlushingEventListener.flushE verythingToExecutions(AbstractFlushingEventListener.java:65)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(De faultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
at org.eclipse.emf.teneo.hibernate.resource.HibernateResource.s aveResource(HibernateResource.java:210)
... 34 more


--------------090905090207090701020804
Content-Type: image/jpeg;
name="model.jpg"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="model.jpg"

/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJ ChQODwwQFxQY
GBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoI ChMKChMoGhYa
KCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgo KCgoKCj/wAAR
CAB+AasDASIAAhEBAxEB/8QAHAABAQADAQEBAQAAAAAAAAAAAAYEBQcDCAIB /8QARRAAAQQB
AgIHBAcGBQMDBQAAAQACAwQFBhESEwcUIVRWk9MWFyIxFTdBdZaz1CMyNpXS 8CRCUWFzM3Gy
JTSBSFOGkcT/xAAYAQEBAQEBAAAAAAAAAAAAAAAAAQIDBP/EABwRAQEBAAMB AQEAAAAAAAAA
AAABEQISIQMxUf/aAAwDAQACEQMRAD8A+qUREBERAREQEREBERAREQEREBER AREQEREBERAR
EQEREBERAREQEREBERAREQEREBERAREQEREBERAREQEREBERAREQEREBERAR TfSXano9HGq7
dOaSC1XxNuWKWN3C6N7YXFrgR8iCAd14+weI75qT8R5H10FUilfYPEd81J+I 8j66eweI75qT
8R5H10FUilfYPEd81J+I8j66eweI75qT8R5H10FUihbWntJ07DoLefy8E7Nu KOXVd5rhuNxu
DY3+RWRR0jp2/EZaOVztmIO4S+HU994B+e24n+faP/2szlxtyVcv6skUr7B4 jvmpPxHkfXT2
DxHfNSfiPI+utIqkUr7B4jvmpPxHkfXT2DxHfNSfiPI+ugqkUr7B4jvmpPxH kfXT2DxHfNSf
iPI+ugqkUr7B4jvmpPxHkfXT2DxHfNSfiPI+ugqkUr7B4jvmpPxHkfXT2DxH fNSfiPI+ugqk
Ur7B4jvmpPxHkfXT2DxHfNSfiPI+ugqkXJNSPl0T0jaRgw9zKSVMlDcbbr3s lYuMk4HV+Ejn
PfwEcbu1u3z7dx2LraAiIgIiICIiAiIgIiICIiAii9VUxlte4DGWbWRhovxl +y+OlfnqF8jJ
abWFzontJ2Ej+wnb4lleweI75qT8R5H10FUilfYPEd81J+I8j66eweI75qT8 R5H10FUilfYP
Ed81J+I8j66eweI75qT8R5H10FUilfYPEd81J+I8j66eweI75qT8R5H10FUi lfYPEd81J+I8
j66eweI75qT8R5H10FUilfYPEd81J+I8j66eweI75qT8R5H10FUi5t0gaVpY bQWpMnjshqSK
9SxlmzBIdQ33hkjInOaeF0xB2IHYQQftVP0f5ezm9KUbl7hNlzA2R7RtxkD9 7b7N/wDbs/7f
JBRIiICIiAiIglelj6rNZfct38h6qlK9LH1Way+5bv5D1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4R1Z5Nb1099FLwjqzya3roKCfQDTcq2K Oo83Q6tNbsxR
QirIxstmaSWSQCWB/wAX7VzA75hhIH7zy6wrRPhjLZJ5Z3F738cgaCA5xIb8 IA2aCGjs32A3
JO5PL/fRS8I6s8mt66e+il4R1Z5Nb10HRcHioMNSkq1XyvjktWLZMhBPHNM+ Z47AOwOkIH+2
3z+a2C5V76KXhHVnk1vXT30UvCOrPJreug6qi5V76KXhHVnk1vXT30UvCOrP Jreugq+lj6rN
Zfct38h6xuiL+BqP9/YFB636U4c9ozP4eppTU8dnIY+xUifLFXDGvkjc0FxE xO25G+wP/ZXv
RI0t0RTa4EOBIII2IOwQWSIiAiIgIiICIiAiIgIiICIiAiIgIiICIiAiIgIi ICIiAiIgIiIC
IiAiIgIiICIiAiIg/jmhzS1wBaRsQRuCF4dRqd1g8sLIRBj9Rqd1g8sJ1Gp3 WDywshEGP1Gp
3WDywnUandYPLCyEQY/UandYPLCdRqd1g8sLIRBj9Rqd1g8sJ1Gp3WDywshE GP1Gp3WDywnU
andYPLCyEQY/UandYPLC9Yoo4WlsMbI2k77NaAN1+0QEREH/2Q==
--------------090905090207090701020804--
Re: [teneo] Exception when using Enums [message #58830 is a reply to message #58730] Tue, 24 October 2006 05:48 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Hans,
I have a testcase which tests this and it works. This exception can occur when you try to save an
object in two different sessions. This occurs for example if you have references between objects in
different resources. If you save one resource then the refered object in the other resource is also
saved, when you then save the second resource this error occurs. Also the name of your testcase
seems to refer to this.
If this is the case then you can use a SessionController (url probably truncated by line break):
http://www.elver.org/hibernate/hibernateresources.html#Shari ng+one+Session+between+Resources%2C+One+transaction+when+sav ing+multiple+resources

to share a session between resources.

gr. Martin

Hans Mueller-Dieckert wrote:
> Hi Martin and everybody else reading this !
>
> I have an enum MyEnum in my model and a class which has an attribute
> with the type MyEnum. When I have a single object, set the attribute and
> save everything in a HibernateResource, everything works fine.
>
> But having two objects, where the attribute for both objects is set to
> the same enmu-literal, I get an Exception.
>
> This is the code which does not work:
>
> Resource dbResource = domain.getResourceSet().getResource(uri, true);
>
>
> TestClass element1 = TestmodelFactory.eINSTANCE.createTestClass();
> element1.setEnumProperty(TestEnum.ITEM1_LITERAL);
> dbResource.getContents().add(element1);
>
> TestClass element2 = TestmodelFactory.eINSTANCE.createTestClass();
> element2.setEnumProperty(TestEnum.ITEM1_LITERAL);
> dbResource.getContents().add(element2);
>
> dbResource.save(null);
>
>
> I'll also attach a little screenshot describing the model and the
> exception stack trace.
>
> greetings,
> Hans
>
>
> ------------------------------------------------------------ ------------
>
> org.eclipse.emf.teneo.hibernate.HbStoreException: Exception when saving resource test
> at org.eclipse.emf.teneo.hibernate.resource.HibernateResource.s aveResource(HibernateResource.java:214)
> at org.eclipse.emf.teneo.resource.StoreResource.save(StoreResou rce.java:271)
> at de.arcsolutions.remarc.platform.emftest.TwoResourcesLinkTest Case.testTwoResources(TwoResourcesLinkTestCase.java:77)
> 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 junit.framework.TestSuite.runTest(TestSuite.java:208)
> at junit.framework.TestSuite.run(TestSuite.java:203)
> at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestRefer ence.run(JUnit3TestReference.java:128)
> at org.eclipse.jdt.internal.junit.runner.TestExecution.run(Test Execution.java:38)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:460)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
> at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunne r.main(RemotePluginTestRunner.java:58)
> at org.eclipse.pde.internal.junit.runtime.CoreTestApplication.r un(CoreTestApplication.java:24)
> at org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:78)
> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:92)
> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:68)
> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:400)
> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:177)
> 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 org.eclipse.core.launcher.Main.invokeFramework(Main.java:336 )
> at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
> at org.eclipse.core.launcher.Main.run(Main.java:977)
> at org.eclipse.core.launcher.Main.main(Main.java:952)
> Caused by: org.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions
> at org.hibernate.collection.AbstractPersistentCollection.setCur rentSession(AbstractPersistentCollection.java:410)
> at org.hibernate.event.def.OnUpdateVisitor.processCollection(On UpdateVisitor.java:40)
> at org.hibernate.event.def.AbstractVisitor.processValue(Abstrac tVisitor.java:101)
> at org.hibernate.event.def.AbstractVisitor.processValue(Abstrac tVisitor.java:61)
> at org.hibernate.event.def.AbstractVisitor.processEntityPropert yValues(AbstractVisitor.java:55)
> at org.hibernate.event.def.AbstractVisitor.process(AbstractVisi tor.java:123)
> at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formUpdate(DefaultSaveOrUpdateEventListener.java:267)
> at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsDetached(DefaultSaveOrUpdateEventListener.java:216)
> at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
> at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
> at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl. java:502)
> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :494)
> at org.hibernate.engine.CascadingAction$1.cascade(CascadingActi on.java:134)
> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:213)
> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java :157)
> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:10 8)
> at org.hibernate.engine.Cascade.cascade(Cascade.java:248)
> at org.hibernate.engine.Cascade.cascade(Cascade.java:223)
> at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.cas cadeOnUpdate(DefaultSaveOrUpdateEventListener.java:331)
> at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formUpdate(DefaultSaveOrUpdateEventListener.java:303)
> at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsDetached(DefaultSaveOrUpdateEventListener.java:216)
> at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
> at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
> at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl. java:502)
> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :494)
> at org.hibernate.engine.CascadingAction$1.cascade(CascadingActi on.java:134)
> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:213)
> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java :157)
> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:10 8)
> at org.hibernate.engine.Cascade.cascade(Cascade.java:248)
> at org.hibernate.event.def.AbstractFlushingEventListener.cascad eOnFlush(AbstractFlushingEventListener.java:130)
> at org.hibernate.event.def.AbstractFlushingEventListener.prepar eEntityFlushes(AbstractFlushingEventListener.java:121)
> at org.hibernate.event.def.AbstractFlushingEventListener.flushE verythingToExecutions(AbstractFlushingEventListener.java:65)
> at org.hibernate.event.def.DefaultFlushEventListener.onFlush(De faultFlushEventListener.java:26)
> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
> at org.eclipse.emf.teneo.hibernate.resource.HibernateResource.s aveResource(HibernateResource.java:210)
> ... 34 more
>
>
>
> ------------------------------------------------------------ ------------
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [teneo] Exception when using Enums [message #58906 is a reply to message #58830] Tue, 24 October 2006 07:40 Go to previous messageGo to next message
Hans Mueller-Dieckert is currently offline Hans Mueller-DieckertFriend
Messages: 32
Registered: July 2009
Member
Hi Martin,

I save everything in a single resource. The name of the test case is
just because I changed an old test case when trying to check out if I
can reproduce the Exception with a test case.
The funny thing is, that when I'm commenting out the marked lines down
below and run the test case twice, the second time it fails.

If you want to, I could provide you the project containing the testmodel
and the test case.

For now, here is my full testcode:


final String dataStoreName = "enumtest";

final HbDataStore dataStore =
HbHelper.INSTANCE.createRegisterDataStore(dataStoreName);

EPackage[] packages = new EPackage[] {TestmodelPackage.eINSTANCE};

dataStore.setEPackages(packages);

Properties properties = new Properties();

properties.setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver");
properties.setProperty("hibernate.connection.url","jdbc:mysql://127.0.0.1:3306/enumtest");
properties.setProperty("hibernate.connection.username","root ");
properties.setProperty("hibernate.connection.password","system ");
properties.setProperty("hibernate.dialect","org.hibernate.dialect.MySQLInnoDBDialect ");

dataStore.setHibernateProperties(properties);

dataStore.initialize();

EditingDomain domain = new AdapterFactoryEditingDomain(new
ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Reg istry.INSTANCE),new
BasicCommandStack());

String uriStr = "hibernate://?" + HibernateResource.DS_NAME_PARAM +
"=enumtest";
URI uri = URI.createURI(uriStr);
Resource dbResource = domain.getResourceSet().getResource(uri, true);

TestClass element1 = TestmodelFactory.eINSTANCE.createTestClass();
element1.setEnumProperty(TestEnum.ITEM1_LITERAL);
dbResource.getContents().add(element1);

// Commenting the following lines out brings up an Exception when
// running the test case twice
TestClass element2 = TestmodelFactory.eINSTANCE.createTestClass();
element2.setEnumProperty(TestEnum.ITEM1_LITERAL);
dbResource.getContents().add(element2);

dbResource.save(null);

reetings,
Hans

Martin Taal schrieb:
> Hi Hans,
> I have a testcase which tests this and it works. This exception can
> occur when you try to save an object in two different sessions. This
> occurs for example if you have references between objects in different
> resources. If you save one resource then the refered object in the other
> resource is also saved, when you then save the second resource this
> error occurs. Also the name of your testcase seems to refer to this.
> If this is the case then you can use a SessionController (url probably
> truncated by line break):
> http://www.elver.org/hibernate/hibernateresources.html#Shari ng+one+Session+between+Resources%2C+One+transaction+when+sav ing+multiple+resources
>
>
> to share a session between resources.
>
> gr. Martin
>
Re: [teneo] Exception when using Enums [message #58957 is a reply to message #58906] Tue, 24 October 2006 09:41 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Hans,
Can you send me the test project and test case?
So if you don't comment out the lines then running twice does not result in an error?

gr. Martin

Hans Mueller-Dieckert wrote:
> Hi Martin,
>
> I save everything in a single resource. The name of the test case is
> just because I changed an old test case when trying to check out if I
> can reproduce the Exception with a test case.
> The funny thing is, that when I'm commenting out the marked lines down
> below and run the test case twice, the second time it fails.
>
> If you want to, I could provide you the project containing the testmodel
> and the test case.
>
> For now, here is my full testcode:
>
>
> final String dataStoreName = "enumtest";
>
> final HbDataStore dataStore =
> HbHelper.INSTANCE.createRegisterDataStore(dataStoreName);
>
> EPackage[] packages = new EPackage[] {TestmodelPackage.eINSTANCE};
>
> dataStore.setEPackages(packages);
>
> Properties properties = new Properties();
>
> properties.setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver");
>
> properties.setProperty("hibernate.connection.url","jdbc:mysql://127.0.0.1:3306/enumtest");
>
> properties.setProperty("hibernate.connection.username","root ");
> properties.setProperty("hibernate.connection.password","system ");
> properties.setProperty("hibernate.dialect","org.hibernate.dialect.MySQLInnoDBDialect ");
>
>
> dataStore.setHibernateProperties(properties);
>
> dataStore.initialize();
>
> EditingDomain domain = new AdapterFactoryEditingDomain(new
> ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Reg istry.INSTANCE),new
> BasicCommandStack());
>
> String uriStr = "hibernate://?" + HibernateResource.DS_NAME_PARAM +
> "=enumtest";
> URI uri = URI.createURI(uriStr);
> Resource dbResource = domain.getResourceSet().getResource(uri, true);
>
> TestClass element1 = TestmodelFactory.eINSTANCE.createTestClass();
> element1.setEnumProperty(TestEnum.ITEM1_LITERAL);
> dbResource.getContents().add(element1);
>
> // Commenting the following lines out brings up an Exception when
> // running the test case twice
> TestClass element2 = TestmodelFactory.eINSTANCE.createTestClass();
> element2.setEnumProperty(TestEnum.ITEM1_LITERAL);
> dbResource.getContents().add(element2);
>
> dbResource.save(null);
>
> reetings,
> Hans
>
> Martin Taal schrieb:
>> Hi Hans,
>> I have a testcase which tests this and it works. This exception can
>> occur when you try to save an object in two different sessions. This
>> occurs for example if you have references between objects in different
>> resources. If you save one resource then the refered object in the
>> other resource is also saved, when you then save the second resource
>> this error occurs. Also the name of your testcase seems to refer to this.
>> If this is the case then you can use a SessionController (url probably
>> truncated by line break):
>> http://www.elver.org/hibernate/hibernateresources.html#Shari ng+one+Session+between+Resources%2C+One+transaction+when+sav ing+multiple+resources
>>
>>
>> to share a session between resources.
>>
>> gr. Martin
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [teneo] Exception when using Enums [message #59009 is a reply to message #58957] Tue, 24 October 2006 10:27 Go to previous messageGo to next message
Hans Mueller-Dieckert is currently offline Hans Mueller-DieckertFriend
Messages: 32
Registered: July 2009
Member
Hi Martin,

I'll send you the Project soon via mail. When not commenting out these
lines I can't even run the test case once without an exception.

greeting,
Hans


Martin Taal schrieb:
> Hi Hans,
> Can you send me the test project and test case?
> So if you don't comment out the lines then running twice does not result
> in an error?
>
> gr. Martin
>
> Hans Mueller-Dieckert wrote:
>> Hi Martin,
>>
>> I save everything in a single resource. The name of the test case is
>> just because I changed an old test case when trying to check out if I
>> can reproduce the Exception with a test case.
>> The funny thing is, that when I'm commenting out the marked lines down
>> below and run the test case twice, the second time it fails.
>>
>> If you want to, I could provide you the project containing the
>> testmodel and the test case.
>>
>> For now, here is my full testcode:
>>
>>
>> final String dataStoreName = "enumtest";
>> final HbDataStore dataStore =
>> HbHelper.INSTANCE.createRegisterDataStore(dataStoreName);
>>
>> EPackage[] packages = new EPackage[] {TestmodelPackage.eINSTANCE};
>> dataStore.setEPackages(packages);
>> Properties properties = new Properties();
>>
>> properties.setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver");
>>
>> properties.setProperty("hibernate.connection.url","jdbc:mysql://127.0.0.1:3306/enumtest");
>>
>> properties.setProperty("hibernate.connection.username","root ");
>> properties.setProperty("hibernate.connection.password","system ");
>> properties.setProperty("hibernate.dialect","org.hibernate.dialect.MySQLInnoDBDialect ");
>>
>>
>> dataStore.setHibernateProperties(properties);
>>
>> dataStore.initialize();
>> EditingDomain domain = new AdapterFactoryEditingDomain(new
>> ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Reg istry.INSTANCE),new
>> BasicCommandStack());
>>
>> String uriStr = "hibernate://?" + HibernateResource.DS_NAME_PARAM +
>> "=enumtest";
>> URI uri = URI.createURI(uriStr);
>> Resource dbResource = domain.getResourceSet().getResource(uri, true);
>> TestClass element1 = TestmodelFactory.eINSTANCE.createTestClass();
>> element1.setEnumProperty(TestEnum.ITEM1_LITERAL);
>> dbResource.getContents().add(element1);
>> // Commenting the following lines out brings up an Exception when
>> // running the test case twice
>> TestClass element2 = TestmodelFactory.eINSTANCE.createTestClass();
>> element2.setEnumProperty(TestEnum.ITEM1_LITERAL);
>> dbResource.getContents().add(element2);
>> dbResource.save(null);
>>
>> reetings,
>> Hans
>>
>> Martin Taal schrieb:
>>> Hi Hans,
>>> I have a testcase which tests this and it works. This exception can
>>> occur when you try to save an object in two different sessions. This
>>> occurs for example if you have references between objects in
>>> different resources. If you save one resource then the refered object
>>> in the other resource is also saved, when you then save the second
>>> resource this error occurs. Also the name of your testcase seems to
>>> refer to this.
>>> If this is the case then you can use a SessionController (url
>>> probably truncated by line break):
>>> http://www.elver.org/hibernate/hibernateresources.html#Shari ng+one+Session+between+Resources%2C+One+transaction+when+sav ing+multiple+resources
>>>
>>>
>>> to share a session between resources.
>>>
>>> gr. Martin
>>>
>
>
Re: [teneo] Exception when using Enums [message #59309 is a reply to message #59009] Wed, 25 October 2006 18:55 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Hans,
I tested this and with me the error was that the enum property was set to unique, so I got a unique
constraint violation.
This was caused by a bug that the unique property of an EAttribute was still being used for enum and
lob. I have entered a bugzilla for this:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=162256

I have committed a fix, this will be in the next build (probably friday).

Can you check if setting the unique property of the EnumProperty to false helps? You need to
regenerate the sources for Teneo to see the new unique value as it reads the runtime model.

gr. Martin

Hans Mueller-Dieckert wrote:
> Hi Martin,
>
> I'll send you the Project soon via mail. When not commenting out these
> lines I can't even run the test case once without an exception.
>
> greeting,
> Hans
>
>
> Martin Taal schrieb:
>> Hi Hans,
>> Can you send me the test project and test case?
>> So if you don't comment out the lines then running twice does not
>> result in an error?
>>
>> gr. Martin
>>
>> Hans Mueller-Dieckert wrote:
>>> Hi Martin,
>>>
>>> I save everything in a single resource. The name of the test case is
>>> just because I changed an old test case when trying to check out if I
>>> can reproduce the Exception with a test case.
>>> The funny thing is, that when I'm commenting out the marked lines
>>> down below and run the test case twice, the second time it fails.
>>>
>>> If you want to, I could provide you the project containing the
>>> testmodel and the test case.
>>>
>>> For now, here is my full testcode:
>>>
>>>
>>> final String dataStoreName = "enumtest";
>>> final HbDataStore dataStore =
>>> HbHelper.INSTANCE.createRegisterDataStore(dataStoreName);
>>>
>>> EPackage[] packages = new EPackage[] {TestmodelPackage.eINSTANCE};
>>> dataStore.setEPackages(packages);
>>> Properties properties = new Properties();
>>>
>>> properties.setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver");
>>>
>>> properties.setProperty("hibernate.connection.url","jdbc:mysql://127.0.0.1:3306/enumtest");
>>>
>>> properties.setProperty("hibernate.connection.username","root ");
>>> properties.setProperty("hibernate.connection.password","system ");
>>> properties.setProperty("hibernate.dialect","org.hibernate.dialect.MySQLInnoDBDialect ");
>>>
>>>
>>> dataStore.setHibernateProperties(properties);
>>>
>>> dataStore.initialize();
>>> EditingDomain domain = new AdapterFactoryEditingDomain(new
>>> ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Reg istry.INSTANCE),new
>>> BasicCommandStack());
>>>
>>> String uriStr = "hibernate://?" + HibernateResource.DS_NAME_PARAM +
>>> "=enumtest";
>>> URI uri = URI.createURI(uriStr);
>>> Resource dbResource = domain.getResourceSet().getResource(uri, true);
>>> TestClass element1 = TestmodelFactory.eINSTANCE.createTestClass();
>>> element1.setEnumProperty(TestEnum.ITEM1_LITERAL);
>>> dbResource.getContents().add(element1);
>>> // Commenting the following lines out brings up an Exception when
>>> // running the test case twice
>>> TestClass element2 = TestmodelFactory.eINSTANCE.createTestClass();
>>> element2.setEnumProperty(TestEnum.ITEM1_LITERAL);
>>> dbResource.getContents().add(element2);
>>> dbResource.save(null);
>>>
>>> reetings,
>>> Hans
>>>
>>> Martin Taal schrieb:
>>>> Hi Hans,
>>>> I have a testcase which tests this and it works. This exception can
>>>> occur when you try to save an object in two different sessions. This
>>>> occurs for example if you have references between objects in
>>>> different resources. If you save one resource then the refered
>>>> object in the other resource is also saved, when you then save the
>>>> second resource this error occurs. Also the name of your testcase
>>>> seems to refer to this.
>>>> If this is the case then you can use a SessionController (url
>>>> probably truncated by line break):
>>>> http://www.elver.org/hibernate/hibernateresources.html#Shari ng+one+Session+between+Resources%2C+One+transaction+when+sav ing+multiple+resources
>>>>
>>>>
>>>> to share a session between resources.
>>>>
>>>> gr. Martin
>>>>
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [teneo] Exception when using Enums [message #594654 is a reply to message #58730] Tue, 24 October 2006 05:48 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Hans,
I have a testcase which tests this and it works. This exception can occur when you try to save an
object in two different sessions. This occurs for example if you have references between objects in
different resources. If you save one resource then the refered object in the other resource is also
saved, when you then save the second resource this error occurs. Also the name of your testcase
seems to refer to this.
If this is the case then you can use a SessionController (url probably truncated by line break):
http://www.elver.org/hibernate/hibernateresources.html#Shari ng+one+Session+between+Resources%2C+One+transaction+when+sav ing+multiple+resources

to share a session between resources.

gr. Martin

Hans Mueller-Dieckert wrote:
> Hi Martin and everybody else reading this !
>
> I have an enum MyEnum in my model and a class which has an attribute
> with the type MyEnum. When I have a single object, set the attribute and
> save everything in a HibernateResource, everything works fine.
>
> But having two objects, where the attribute for both objects is set to
> the same enmu-literal, I get an Exception.
>
> This is the code which does not work:
>
> Resource dbResource = domain.getResourceSet().getResource(uri, true);
>
>
> TestClass element1 = TestmodelFactory.eINSTANCE.createTestClass();
> element1.setEnumProperty(TestEnum.ITEM1_LITERAL);
> dbResource.getContents().add(element1);
>
> TestClass element2 = TestmodelFactory.eINSTANCE.createTestClass();
> element2.setEnumProperty(TestEnum.ITEM1_LITERAL);
> dbResource.getContents().add(element2);
>
> dbResource.save(null);
>
>
> I'll also attach a little screenshot describing the model and the
> exception stack trace.
>
> greetings,
> Hans
>
>
> ------------------------------------------------------------ ------------
>
> org.eclipse.emf.teneo.hibernate.HbStoreException: Exception when saving resource test
> at org.eclipse.emf.teneo.hibernate.resource.HibernateResource.s aveResource(HibernateResource.java:214)
> at org.eclipse.emf.teneo.resource.StoreResource.save(StoreResou rce.java:271)
> at de.arcsolutions.remarc.platform.emftest.TwoResourcesLinkTest Case.testTwoResources(TwoResourcesLinkTestCase.java:77)
> 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 junit.framework.TestSuite.runTest(TestSuite.java:208)
> at junit.framework.TestSuite.run(TestSuite.java:203)
> at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestRefer ence.run(JUnit3TestReference.java:128)
> at org.eclipse.jdt.internal.junit.runner.TestExecution.run(Test Execution.java:38)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:460)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
> at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunne r.main(RemotePluginTestRunner.java:58)
> at org.eclipse.pde.internal.junit.runtime.CoreTestApplication.r un(CoreTestApplication.java:24)
> at org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:78)
> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:92)
> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:68)
> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:400)
> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:177)
> 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 org.eclipse.core.launcher.Main.invokeFramework(Main.java:336 )
> at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
> at org.eclipse.core.launcher.Main.run(Main.java:977)
> at org.eclipse.core.launcher.Main.main(Main.java:952)
> Caused by: org.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions
> at org.hibernate.collection.AbstractPersistentCollection.setCur rentSession(AbstractPersistentCollection.java:410)
> at org.hibernate.event.def.OnUpdateVisitor.processCollection(On UpdateVisitor.java:40)
> at org.hibernate.event.def.AbstractVisitor.processValue(Abstrac tVisitor.java:101)
> at org.hibernate.event.def.AbstractVisitor.processValue(Abstrac tVisitor.java:61)
> at org.hibernate.event.def.AbstractVisitor.processEntityPropert yValues(AbstractVisitor.java:55)
> at org.hibernate.event.def.AbstractVisitor.process(AbstractVisi tor.java:123)
> at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formUpdate(DefaultSaveOrUpdateEventListener.java:267)
> at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsDetached(DefaultSaveOrUpdateEventListener.java:216)
> at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
> at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
> at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl. java:502)
> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :494)
> at org.hibernate.engine.CascadingAction$1.cascade(CascadingActi on.java:134)
> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:213)
> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java :157)
> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:10 8)
> at org.hibernate.engine.Cascade.cascade(Cascade.java:248)
> at org.hibernate.engine.Cascade.cascade(Cascade.java:223)
> at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.cas cadeOnUpdate(DefaultSaveOrUpdateEventListener.java:331)
> at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formUpdate(DefaultSaveOrUpdateEventListener.java:303)
> at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsDetached(DefaultSaveOrUpdateEventListener.java:216)
> at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
> at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
> at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl. java:502)
> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :494)
> at org.hibernate.engine.CascadingAction$1.cascade(CascadingActi on.java:134)
> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:213)
> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java :157)
> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:10 8)
> at org.hibernate.engine.Cascade.cascade(Cascade.java:248)
> at org.hibernate.event.def.AbstractFlushingEventListener.cascad eOnFlush(AbstractFlushingEventListener.java:130)
> at org.hibernate.event.def.AbstractFlushingEventListener.prepar eEntityFlushes(AbstractFlushingEventListener.java:121)
> at org.hibernate.event.def.AbstractFlushingEventListener.flushE verythingToExecutions(AbstractFlushingEventListener.java:65)
> at org.hibernate.event.def.DefaultFlushEventListener.onFlush(De faultFlushEventListener.java:26)
> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
> at org.eclipse.emf.teneo.hibernate.resource.HibernateResource.s aveResource(HibernateResource.java:210)
> ... 34 more
>
>
>
> ------------------------------------------------------------ ------------
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [teneo] Exception when using Enums [message #594679 is a reply to message #58830] Tue, 24 October 2006 07:40 Go to previous message
Hans Mueller-Dieckert is currently offline Hans Mueller-DieckertFriend
Messages: 32
Registered: July 2009
Member
Hi Martin,

I save everything in a single resource. The name of the test case is
just because I changed an old test case when trying to check out if I
can reproduce the Exception with a test case.
The funny thing is, that when I'm commenting out the marked lines down
below and run the test case twice, the second time it fails.

If you want to, I could provide you the project containing the testmodel
and the test case.

For now, here is my full testcode:


final String dataStoreName = "enumtest";

final HbDataStore dataStore =
HbHelper.INSTANCE.createRegisterDataStore(dataStoreName);

EPackage[] packages = new EPackage[] {TestmodelPackage.eINSTANCE};

dataStore.setEPackages(packages);

Properties properties = new Properties();

properties.setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver");
properties.setProperty("hibernate.connection.url","jdbc:mysql://127.0.0.1:3306/enumtest");
properties.setProperty("hibernate.connection.username","root ");
properties.setProperty("hibernate.connection.password","system ");
properties.setProperty("hibernate.dialect","org.hibernate.dialect.MySQLInnoDBDialect ");

dataStore.setHibernateProperties(properties);

dataStore.initialize();

EditingDomain domain = new AdapterFactoryEditingDomain(new
ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Reg istry.INSTANCE),new
BasicCommandStack());

String uriStr = "hibernate://?" + HibernateResource.DS_NAME_PARAM +
"=enumtest";
URI uri = URI.createURI(uriStr);
Resource dbResource = domain.getResourceSet().getResource(uri, true);

TestClass element1 = TestmodelFactory.eINSTANCE.createTestClass();
element1.setEnumProperty(TestEnum.ITEM1_LITERAL);
dbResource.getContents().add(element1);

// Commenting the following lines out brings up an Exception when
// running the test case twice
TestClass element2 = TestmodelFactory.eINSTANCE.createTestClass();
element2.setEnumProperty(TestEnum.ITEM1_LITERAL);
dbResource.getContents().add(element2);

dbResource.save(null);

reetings,
Hans

Martin Taal schrieb:
> Hi Hans,
> I have a testcase which tests this and it works. This exception can
> occur when you try to save an object in two different sessions. This
> occurs for example if you have references between objects in different
> resources. If you save one resource then the refered object in the other
> resource is also saved, when you then save the second resource this
> error occurs. Also the name of your testcase seems to refer to this.
> If this is the case then you can use a SessionController (url probably
> truncated by line break):
> http://www.elver.org/hibernate/hibernateresources.html#Shari ng+one+Session+between+Resources%2C+One+transaction+when+sav ing+multiple+resources
>
>
> to share a session between resources.
>
> gr. Martin
>
Re: [teneo] Exception when using Enums [message #594695 is a reply to message #58906] Tue, 24 October 2006 09:41 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Hans,
Can you send me the test project and test case?
So if you don't comment out the lines then running twice does not result in an error?

gr. Martin

Hans Mueller-Dieckert wrote:
> Hi Martin,
>
> I save everything in a single resource. The name of the test case is
> just because I changed an old test case when trying to check out if I
> can reproduce the Exception with a test case.
> The funny thing is, that when I'm commenting out the marked lines down
> below and run the test case twice, the second time it fails.
>
> If you want to, I could provide you the project containing the testmodel
> and the test case.
>
> For now, here is my full testcode:
>
>
> final String dataStoreName = "enumtest";
>
> final HbDataStore dataStore =
> HbHelper.INSTANCE.createRegisterDataStore(dataStoreName);
>
> EPackage[] packages = new EPackage[] {TestmodelPackage.eINSTANCE};
>
> dataStore.setEPackages(packages);
>
> Properties properties = new Properties();
>
> properties.setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver");
>
> properties.setProperty("hibernate.connection.url","jdbc:mysql://127.0.0.1:3306/enumtest");
>
> properties.setProperty("hibernate.connection.username","root ");
> properties.setProperty("hibernate.connection.password","system ");
> properties.setProperty("hibernate.dialect","org.hibernate.dialect.MySQLInnoDBDialect ");
>
>
> dataStore.setHibernateProperties(properties);
>
> dataStore.initialize();
>
> EditingDomain domain = new AdapterFactoryEditingDomain(new
> ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Reg istry.INSTANCE),new
> BasicCommandStack());
>
> String uriStr = "hibernate://?" + HibernateResource.DS_NAME_PARAM +
> "=enumtest";
> URI uri = URI.createURI(uriStr);
> Resource dbResource = domain.getResourceSet().getResource(uri, true);
>
> TestClass element1 = TestmodelFactory.eINSTANCE.createTestClass();
> element1.setEnumProperty(TestEnum.ITEM1_LITERAL);
> dbResource.getContents().add(element1);
>
> // Commenting the following lines out brings up an Exception when
> // running the test case twice
> TestClass element2 = TestmodelFactory.eINSTANCE.createTestClass();
> element2.setEnumProperty(TestEnum.ITEM1_LITERAL);
> dbResource.getContents().add(element2);
>
> dbResource.save(null);
>
> reetings,
> Hans
>
> Martin Taal schrieb:
>> Hi Hans,
>> I have a testcase which tests this and it works. This exception can
>> occur when you try to save an object in two different sessions. This
>> occurs for example if you have references between objects in different
>> resources. If you save one resource then the refered object in the
>> other resource is also saved, when you then save the second resource
>> this error occurs. Also the name of your testcase seems to refer to this.
>> If this is the case then you can use a SessionController (url probably
>> truncated by line break):
>> http://www.elver.org/hibernate/hibernateresources.html#Shari ng+one+Session+between+Resources%2C+One+transaction+when+sav ing+multiple+resources
>>
>>
>> to share a session between resources.
>>
>> gr. Martin
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [teneo] Exception when using Enums [message #594709 is a reply to message #58957] Tue, 24 October 2006 10:27 Go to previous message
Hans Mueller-Dieckert is currently offline Hans Mueller-DieckertFriend
Messages: 32
Registered: July 2009
Member
Hi Martin,

I'll send you the Project soon via mail. When not commenting out these
lines I can't even run the test case once without an exception.

greeting,
Hans


Martin Taal schrieb:
> Hi Hans,
> Can you send me the test project and test case?
> So if you don't comment out the lines then running twice does not result
> in an error?
>
> gr. Martin
>
> Hans Mueller-Dieckert wrote:
>> Hi Martin,
>>
>> I save everything in a single resource. The name of the test case is
>> just because I changed an old test case when trying to check out if I
>> can reproduce the Exception with a test case.
>> The funny thing is, that when I'm commenting out the marked lines down
>> below and run the test case twice, the second time it fails.
>>
>> If you want to, I could provide you the project containing the
>> testmodel and the test case.
>>
>> For now, here is my full testcode:
>>
>>
>> final String dataStoreName = "enumtest";
>> final HbDataStore dataStore =
>> HbHelper.INSTANCE.createRegisterDataStore(dataStoreName);
>>
>> EPackage[] packages = new EPackage[] {TestmodelPackage.eINSTANCE};
>> dataStore.setEPackages(packages);
>> Properties properties = new Properties();
>>
>> properties.setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver");
>>
>> properties.setProperty("hibernate.connection.url","jdbc:mysql://127.0.0.1:3306/enumtest");
>>
>> properties.setProperty("hibernate.connection.username","root ");
>> properties.setProperty("hibernate.connection.password","system ");
>> properties.setProperty("hibernate.dialect","org.hibernate.dialect.MySQLInnoDBDialect ");
>>
>>
>> dataStore.setHibernateProperties(properties);
>>
>> dataStore.initialize();
>> EditingDomain domain = new AdapterFactoryEditingDomain(new
>> ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Reg istry.INSTANCE),new
>> BasicCommandStack());
>>
>> String uriStr = "hibernate://?" + HibernateResource.DS_NAME_PARAM +
>> "=enumtest";
>> URI uri = URI.createURI(uriStr);
>> Resource dbResource = domain.getResourceSet().getResource(uri, true);
>> TestClass element1 = TestmodelFactory.eINSTANCE.createTestClass();
>> element1.setEnumProperty(TestEnum.ITEM1_LITERAL);
>> dbResource.getContents().add(element1);
>> // Commenting the following lines out brings up an Exception when
>> // running the test case twice
>> TestClass element2 = TestmodelFactory.eINSTANCE.createTestClass();
>> element2.setEnumProperty(TestEnum.ITEM1_LITERAL);
>> dbResource.getContents().add(element2);
>> dbResource.save(null);
>>
>> reetings,
>> Hans
>>
>> Martin Taal schrieb:
>>> Hi Hans,
>>> I have a testcase which tests this and it works. This exception can
>>> occur when you try to save an object in two different sessions. This
>>> occurs for example if you have references between objects in
>>> different resources. If you save one resource then the refered object
>>> in the other resource is also saved, when you then save the second
>>> resource this error occurs. Also the name of your testcase seems to
>>> refer to this.
>>> If this is the case then you can use a SessionController (url
>>> probably truncated by line break):
>>> http://www.elver.org/hibernate/hibernateresources.html#Shari ng+one+Session+between+Resources%2C+One+transaction+when+sav ing+multiple+resources
>>>
>>>
>>> to share a session between resources.
>>>
>>> gr. Martin
>>>
>
>
Re: [teneo] Exception when using Enums [message #594831 is a reply to message #59009] Wed, 25 October 2006 18:55 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Hans,
I tested this and with me the error was that the enum property was set to unique, so I got a unique
constraint violation.
This was caused by a bug that the unique property of an EAttribute was still being used for enum and
lob. I have entered a bugzilla for this:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=162256

I have committed a fix, this will be in the next build (probably friday).

Can you check if setting the unique property of the EnumProperty to false helps? You need to
regenerate the sources for Teneo to see the new unique value as it reads the runtime model.

gr. Martin

Hans Mueller-Dieckert wrote:
> Hi Martin,
>
> I'll send you the Project soon via mail. When not commenting out these
> lines I can't even run the test case once without an exception.
>
> greeting,
> Hans
>
>
> Martin Taal schrieb:
>> Hi Hans,
>> Can you send me the test project and test case?
>> So if you don't comment out the lines then running twice does not
>> result in an error?
>>
>> gr. Martin
>>
>> Hans Mueller-Dieckert wrote:
>>> Hi Martin,
>>>
>>> I save everything in a single resource. The name of the test case is
>>> just because I changed an old test case when trying to check out if I
>>> can reproduce the Exception with a test case.
>>> The funny thing is, that when I'm commenting out the marked lines
>>> down below and run the test case twice, the second time it fails.
>>>
>>> If you want to, I could provide you the project containing the
>>> testmodel and the test case.
>>>
>>> For now, here is my full testcode:
>>>
>>>
>>> final String dataStoreName = "enumtest";
>>> final HbDataStore dataStore =
>>> HbHelper.INSTANCE.createRegisterDataStore(dataStoreName);
>>>
>>> EPackage[] packages = new EPackage[] {TestmodelPackage.eINSTANCE};
>>> dataStore.setEPackages(packages);
>>> Properties properties = new Properties();
>>>
>>> properties.setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver");
>>>
>>> properties.setProperty("hibernate.connection.url","jdbc:mysql://127.0.0.1:3306/enumtest");
>>>
>>> properties.setProperty("hibernate.connection.username","root ");
>>> properties.setProperty("hibernate.connection.password","system ");
>>> properties.setProperty("hibernate.dialect","org.hibernate.dialect.MySQLInnoDBDialect ");
>>>
>>>
>>> dataStore.setHibernateProperties(properties);
>>>
>>> dataStore.initialize();
>>> EditingDomain domain = new AdapterFactoryEditingDomain(new
>>> ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Reg istry.INSTANCE),new
>>> BasicCommandStack());
>>>
>>> String uriStr = "hibernate://?" + HibernateResource.DS_NAME_PARAM +
>>> "=enumtest";
>>> URI uri = URI.createURI(uriStr);
>>> Resource dbResource = domain.getResourceSet().getResource(uri, true);
>>> TestClass element1 = TestmodelFactory.eINSTANCE.createTestClass();
>>> element1.setEnumProperty(TestEnum.ITEM1_LITERAL);
>>> dbResource.getContents().add(element1);
>>> // Commenting the following lines out brings up an Exception when
>>> // running the test case twice
>>> TestClass element2 = TestmodelFactory.eINSTANCE.createTestClass();
>>> element2.setEnumProperty(TestEnum.ITEM1_LITERAL);
>>> dbResource.getContents().add(element2);
>>> dbResource.save(null);
>>>
>>> reetings,
>>> Hans
>>>
>>> Martin Taal schrieb:
>>>> Hi Hans,
>>>> I have a testcase which tests this and it works. This exception can
>>>> occur when you try to save an object in two different sessions. This
>>>> occurs for example if you have references between objects in
>>>> different resources. If you save one resource then the refered
>>>> object in the other resource is also saved, when you then save the
>>>> second resource this error occurs. Also the name of your testcase
>>>> seems to refer to this.
>>>> If this is the case then you can use a SessionController (url
>>>> probably truncated by line break):
>>>> http://www.elver.org/hibernate/hibernateresources.html#Shari ng+one+Session+between+Resources%2C+One+transaction+when+sav ing+multiple+resources
>>>>
>>>>
>>>> to share a session between resources.
>>>>
>>>> gr. Martin
>>>>
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Previous Topic:Support EMF custom EDataTypes
Next Topic:Custom commit() for Transaction
Goto Forum:
  


Current Time: Wed Jul 17 17:29:07 GMT 2024

Powered by FUDForum. Page generated in 0.04682 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top