[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.tools.emf] Re: [Teneo] Error on session.merge() - EMFInstantiator trying to create instance of abstract class?

Just for anyone who encounters this thread in the future, the Bugzilla can be found at:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=275208

I believe there is enough information there to replicate, but if not I'll certainly try to correct that.

Daniel


Martin Taal wrote:
Hi Daniel,
Can you file a bugzilla for this one? It would be great if you can attach a small test model to it also...


gr. Martin

Daniel Tuohy wrote:
Actually, scratch that! There was a layer of indirection that I had forgotten about. The reference that is causing the trouble is, as you suggest, of the abstract type 'Baz'.

So, with corrections, the actual model is:
- Abstract EClass Baz
- EClass Foo
  - has multi-valued containment reference 'bars' of type Bar
  - has multi-valued containment reference 'biffs' of type Biff
  - extends Baz
- EClass Bar
  - extends Baz
  - has single-valued NON-containment reference 'baz' of type Baz
- EClass Biff
  - extends Baz


And the process that causes the exception is:
(1) Create 'foo' on the server, and save it to the DB using session.save(foo);
(2) Send 'foo' to the client.
(3) Add new Bar 'bar' to foo.bars on the client.
(4) Add new Biff 'biff' to foo.biffs on the client.
(4) Call bar.setBaz(biff) on the client
(5) Send 'foo' back to the server (along with 'bar', via containment).
(6) Update foo in the DB by calling session.merge(foo)


The problem, as far as I can tell, is on the 'baz' field of Bar, which is filled by an object of type Biff.

daniel

Daniel Tuohy wrote:
The reference has elements of type Bar.

Martin Taal wrote:
Hi Daniel,
To be sure the containment reference of Foo.bars has elements of type Bar or type Baz?


btw, as support is given on the main emf newsgroup, I have added it as a cc.

gr. Martin

Daniel Tuohy wrote:
Hello,

I've encountered a strange error when trying to update a teneo hibernated object using Session.merge(). I am using Teneo 1.0.1, but would be open to upgrading if it would help.

Take the following model:

 - Abstract EClass Baz
 - EClass Foo
  - has multi-valued containment reference 'bars' of type Bar
  - extends Baz
 - EClass Bar
  - extends Baz

When I do the following:

(1) Create 'foo' on the server, and save it to the DB using session.save(foo);
(2) Send 'foo' to the client.
(3) Add new Bar 'bar' to foo.bars on the client.
(4) Send 'foo' back to the server (along with 'bar', via containment).
(5) Update foo in the DB by calling session.merge(foo)


I get the following exception:

java.lang.IllegalArgumentException: The class 'Baz' is not a valid classifier
at emf.com.stottlerhenke.adept.impl.AdeptFactoryImpl.create(AdeptFactoryImpl.java:130)


at org.eclipse.emf.ecore.util.EcoreUtil.create(EcoreUtil.java:3169)
at org.eclipse.emf.teneo.hibernate.tuplizer.EMFInstantiator.instantiate(EMFInstantiator.java:85)


at org.hibernate.tuple.entity.AbstractEntityTuplizer.instantiate(AbstractEntityTuplizer.java:374)

at org.hibernate.persister.entity.AbstractEntityPersister.instantiate(AbstractEntityPersister.java:3634)

at org.hibernate.type.EntityType.replace(EntityType.java:278)
at org.hibernate.type.AbstractType.replace(AbstractType.java:177)
at org.hibernate.type.TypeFactory.replace(TypeFactory.java:538)
at org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:429)


at org.hibernate.event.def.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:231)

at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:170)

at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:714)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:696)
at org.hibernate.engine.CascadingAction$6.cascade(CascadingAction.java:268)


at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:291)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:239)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:192)
at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:319)


at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:265)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:242)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:192)
at org.hibernate.engine.Cascade.cascade(Cascade.java:153)
at org.hibernate.event.def.DefaultMergeEventListener.cascadeOnMerge(DefaultMergeEventListener.java:459)


at org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:318)

at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:167)

at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:81)

at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:704)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:688)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:692)
at com.stottlerhenke.adept.server.DataModelServer.updateFoo(DataModelServer.java:443)



The exception seems to occur when processing the new reference to 'bar', and the fact that the reference is multi-valued and containment appears to be important.


Any idea where I might be going wrong?

Thanks,
Daniel