Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo+Hibernate] TransientObjectException while saving a resourc
[Teneo+Hibernate] TransientObjectException while saving a resourc [message #78581] Thu, 05 April 2007 19:54 Go to next message
Markus Bischof is currently offline Markus BischofFriend
Messages: 72
Registered: July 2009
Member
This is a multi-part message in MIME format.

------=_NextPart_000_009B_01C777CC.ED1C3130
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi!

I have a problem saving a resource which was loaded from the filesystem =
as a XMIResourceImpl-Object in the database. I tried the following code =
for small models and it worked fine (There is probably a much better and =
simpler solution for this!)

hibernateResource.getContents().add(xmiResourceImplObject.ge tAllContents(=
).next());
hibResource.save(Collections.EMPTY_MAP);

(Assuming that a resource only contains one root-object).

But now I having trouble saving a bigger model. I get a =
HbMapperException which is caused by a TransientObjectException (at =
least eclipse tells me that) with the message:

"object references an unsaved transient instance - save the transient =
instance before flushing: ReferenceEdge"

So how can I save the "transient instance"?

Regards,
Markus Bischof
------=_NextPart_000_009B_01C777CC.ED1C3130
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.6000.16414" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff background=3D"">
<DIV><FONT face=3DArial size=3D2>Hi!<BR><BR>I have a problem saving a =
resource which=20
was loaded from the filesystem as a XMIResourceImpl-Object in the =
database. I=20
tried the following code for small models and it worked fine (There is =
probably=20
a much better and simpler solution for this!)</FONT></DIV><FONT =
face=3DArial=20
size=3D2>
<DIV><BR> hibernateResource.getContents().add(xmiResourceImplObject.ge tAll=
Contents().next());<BR>hibResource.save(Collections.EMPTY_MAP); </DIV>
<DIV>&nbsp;</DIV>
<DIV>(Assuming that a resource only contains one root-object).</DIV>
<DIV><BR>But now I having trouble saving a bigger model. I get a=20
HbMapperException which is caused by a TransientObjectException (at =
least=20
eclipse tells me that) with the message:</DIV>
<DIV><BR>"object references an unsaved transient instance - save the =
transient=20
instance before flushing: ReferenceEdge"<BR></DIV>
<DIV>So how can I save the "transient instance"?</DIV>
<DIV>&nbsp;</DIV>
<DIV>Regards,</DIV>
<DIV>Markus Bischof</FONT></DIV></BODY></HTML>

------=_NextPart_000_009B_01C777CC.ED1C3130--
Re: [Teneo+Hibernate] TransientObjectException while saving a resourc [message #78625 is a reply to message #78581] Fri, 06 April 2007 07:07 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Markus,
This can be related to the cascade setting on an association. Hb walks the associations, the order
in which objects in the association chain are saved is important. Can you see which association (and
its owning object) is refering to ReferenceEdge? And what does the hbm mapping of this association
look like (the hbmmapping can be retrieved from the hbdatastore using getMappingXML())?

Can you also post the complete stacktrace?

gr. Martin

Markus Bischof wrote:
> Hi!
>
> I have a problem saving a resource which was loaded from the filesystem
> as a XMIResourceImpl-Object in the database. I tried the following code
> for small models and it worked fine (There is probably a much better and
> simpler solution for this!)
>
> hibernateResource.getContents().add(xmiResourceImplObject.ge tAllContents().next());
> hibResource.save(Collections.EMPTY_MAP);
>
> (Assuming that a resource only contains one root-object).
>
> But now I having trouble saving a bigger model. I get a
> HbMapperException which is caused by a TransientObjectException (at
> least eclipse tells me that) with the message:
>
> "object references an unsaved transient instance - save the transient
> instance before flushing: ReferenceEdge"
> So how can I save the "transient instance"?
>
> Regards,
> Markus Bischof


--

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+Hibernate] TransientObjectException while saving a resourc [message #78655 is a reply to message #78625] Fri, 06 April 2007 09:07 Go to previous messageGo to next message
Markus Bischof is currently offline Markus BischofFriend
Messages: 72
Registered: July 2009
Member
Hi Martin!

I've attached the stacktrace and the mapping.xml, which I get when I call
getMappingXML() on the HbDataStore. I also attached the model which causes
the error.

I will post in a few hours which association is refering to
ReferenceEdge...I must first attach the Hibernate-sources to eclipse. I hope
I find that association, but perhaps the mapping.xml and the model give some
first information!

The exception is thrown in the class HibernateResource at line 349:

// now flush everythingif (!hasSessionController) {
mySessionWrapper.flush();
}

Regards,
Markus




Re: [Teneo+Hibernate] TransientObjectException while saving a resourc [message #78672 is a reply to message #78655] Fri, 06 April 2007 11:04 Go to previous messageGo to next message
Markus Bischof is currently offline Markus BischofFriend
Messages: 72
Registered: July 2009
Member
Ok...I hope I have the correct one:

I went through the code and I found out, that the flush-method fails (not
the save-method) in the HibernateResource-object

Line 349: mySessionWrapper.flush();

Then in the flush()-method of the SessionImpl-class, the onFlush()-method of
a DefaultFlushEventListener-class is called, which calls a
performExecutions(...)-method of the AbstractFlushingEventListener.

Line 27: performExecutions(source);

This method calls the method executeActions() of the ActionQueue-class

Line 298: session.getActionQueue().executeActions();

which calls some executeActions(...)-methods, where the
executeActions(collectionCreations)-method fails!

Line 143: executeActions( collectionCreations );

This operation fails for the 141th item in the collectionCreations-list,
which has the collectionRole "Activity.referenceEdges".

I've attached a picture of the variables-view.

How can I give you more information??!?! I guess this is not exactly what
you ment...

Regards,
Markus


  • Attachment: error.JPG
    (Size: 18.44KB, Downloaded 161 times)
Re: [Teneo+Hibernate] TransientObjectException while saving a resourc [message #78688 is a reply to message #78672] Fri, 06 April 2007 13:57 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Can you set a breakpoint and then check which many-to-one (of which class/entity) is handled by the
ManyToOneType (method call to nullSafeSet()) in the stack trace? If you set the breakpoint where
the exception is thrown you can go back in the stacktrace and inspect the members there.

gr. Martin

Markus Bischof wrote:
> Ok...I hope I have the correct one:
>
> I went through the code and I found out, that the flush-method fails (not
> the save-method) in the HibernateResource-object
>
> Line 349: mySessionWrapper.flush();
>
> Then in the flush()-method of the SessionImpl-class, the onFlush()-method of
> a DefaultFlushEventListener-class is called, which calls a
> performExecutions(...)-method of the AbstractFlushingEventListener.
>
> Line 27: performExecutions(source);
>
> This method calls the method executeActions() of the ActionQueue-class
>
> Line 298: session.getActionQueue().executeActions();
>
> which calls some executeActions(...)-methods, where the
> executeActions(collectionCreations)-method fails!
>
> Line 143: executeActions( collectionCreations );
>
> This operation fails for the 141th item in the collectionCreations-list,
> which has the collectionRole "Activity.referenceEdges".
>
> I've attached a picture of the variables-view.
>
> How can I give you more information??!?! I guess this is not exactly what
> you ment...
>
> Regards,
> Markus
>
>
>


--

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+Hibernate] TransientObjectException while saving a resourc [message #78703 is a reply to message #78688] Fri, 06 April 2007 15:06 Go to previous messageGo to next message
Markus Bischof is currently offline Markus BischofFriend
Messages: 72
Registered: July 2009
Member
Ok...

the owner should be an ActivityImpl and the many-to-one should be the
referenceEdges. Here's the mapping code for that one (from the
hibernate.hbm.xml file):

<subclass entity-name="Activity" abstract="false" lazy="false"
extends="PackageableElement" discriminator-value="Activity">
.....
<list name="referenceEdges" lazy="true" cascade="all,delete-orphan">
<key update="true">
<column name="`activity_referenceedges_e_id`" not-null="false"
unique="false"/>
</key>
<list-index column="`activity_referenceedges_idx`"/>
<one-to-many entity-name="ReferenceEdge"/>
</list>
.....
</subclass>

I think that's the collectionRole I mentioned earlier. The collection itself
contains some ReferenceEdgeImpl-objects.
But I did not see a method call to nullSafeSet() in the stacktrace after the
exception. I just have the calls:

HibernateResource(StoreResource).save(...)
HibernateResource.saveResource(...)
HbSessionWrapper.flush()
SessionImpl.flush()
DefaultFlushListener.onFlush(...)
DefaultFlushEventListener(AbstractFlushingEventListener).per formExecutions(...)


Markus
Re: [Teneo+Hibernate] TransientObjectException while saving a resourc [message #78717 is a reply to message #78703] Fri, 06 April 2007 15:16 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
The part of the mapping file you showed here contains the one-to-many (the other side of the
association probably), so not the many-to-one.

I mean this part of the stacktrace (see the fourth line from the top):
Caused by: org.hibernate.TransientObjectException: object references an unsaved transient instance -
save the transient instance before flushing: ReferenceEdge
at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUns aved(ForeignKeys.java:219)
at org.hibernate.type.EntityType.getIdentifier(EntityType.java: 397)
at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.j ava:78)
at
org.hibernate.persister.collection.AbstractCollectionPersist er.writeElement(AbstractCollectionPersister.java:755)


gr. Martin

Markus Bischof wrote:
> Ok...
>
> the owner should be an ActivityImpl and the many-to-one should be the
> referenceEdges. Here's the mapping code for that one (from the
> hibernate.hbm.xml file):
>
> <subclass entity-name="Activity" abstract="false" lazy="false"
> extends="PackageableElement" discriminator-value="Activity">
> .....
> <list name="referenceEdges" lazy="true" cascade="all,delete-orphan">
> <key update="true">
> <column name="`activity_referenceedges_e_id`" not-null="false"
> unique="false"/>
> </key>
> <list-index column="`activity_referenceedges_idx`"/>
> <one-to-many entity-name="ReferenceEdge"/>
> </list>
> .....
> </subclass>
>
> I think that's the collectionRole I mentioned earlier. The collection itself
> contains some ReferenceEdgeImpl-objects.
> But I did not see a method call to nullSafeSet() in the stacktrace after the
> exception. I just have the calls:
>
> HibernateResource(StoreResource).save(...)
> HibernateResource.saveResource(...)
> HbSessionWrapper.flush()
> SessionImpl.flush()
> DefaultFlushListener.onFlush(...)
> DefaultFlushEventListener(AbstractFlushingEventListener).per formExecutions(...)
>
>
> Markus
>
>


--

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+Hibernate] TransientObjectException while saving a resourc [message #78731 is a reply to message #78688] Fri, 06 April 2007 16:17 Go to previous messageGo to next message
Markus Bischof is currently offline Markus BischofFriend
Messages: 72
Registered: July 2009
Member
Ok, now I think that should be the right one:

"ReferenceEdge" should be the many-to-one-type which is handled by the
ManyToOneType (is was named associatedEntityName).

The writeElement-method works fine for the first 9 ReferenceEdgeImpl-Objects
in the list, but the exception is raised when the writeElement-method is
called for the 10th element.

Markus
Re: [Teneo+Hibernate] TransientObjectException while saving a resourc [message #78807 is a reply to message #78717] Sat, 07 April 2007 08:24 Go to previous messageGo to next message
Markus Bischof is currently offline Markus BischofFriend
Messages: 72
Registered: July 2009
Member
Hi Martin,

I created a new plugin project like Michael to show you the error. But the
weird thing is that the model could be saved. There was no
TransientObjectException!

After that I tried to copy the code 1:1 back to my original model. The
important thing was: I have to reload the XMIResourceImpl-object from the
filesystem. I don't know why, but if I create a new ResourceSetImpl, and let
it give me a resource with the same URI as the resource that should be
saved, the following code works fine:

ResourceSet resourceSet = createXMIResourceSet();
URI fileURI = URI.createFileURI(modelToSave.getURI().toFileString());
Resource fileResource = resourceSet.createResource(fileURI);
fileResource.load(Collections.EMPTY_MAP);
HibernateResource hibResource = createHibernateResource(fileResource,
modelName);
hibResource.save(Collections.EMPTY_MAP);



Ok...one thing I noticed in my new plugin-project: When I save the model
(which now works fine) and then in another run, try to delete all the
contents, I get a PropertyValueException:

Caused by: org.hibernate.PropertyValueException: not-null property
references a null or transient value: GuardSpecification.data

I can post the zip-file containing the project and you can look at the
exceptionv if you like.

One last question: How can I copy a resource? For example, when I want to
perform a "Save as"-Action, I want to give the resource a new URI, but I do
not want to loose the old resource-contents. Is there an easy way to do
this?

Kind regards,
Markus
Re: [Teneo+Hibernate] TransientObjectException while saving a resourc [message #78822 is a reply to message #78807] Sat, 07 April 2007 09:36 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Markus,
It is hard to guess why it works now and failed earlier. This type of exception is hard to debug. It
would be easiest for me if you can send me a project zip which fails with preferably a (very) simple
dataset. Then I'll look at it further.

Why the delete action fails with a PropertyValueException I am not sure. Maybe a reference is
cleared because the refered-to object is deleted and the exception is thrown before the referer is
deleted.

I am not sure what 'save as' means in a database contents, do you mean copy to another database?
Regarding the contents of the old resource, if you don't save the resource then the removal of its
content (move contents to another resource) is not persisted to the database.

gr. Martin

Markus Bischof wrote:
> Hi Martin,
>
> I created a new plugin project like Michael to show you the error. But the
> weird thing is that the model could be saved. There was no
> TransientObjectException!
>
> After that I tried to copy the code 1:1 back to my original model. The
> important thing was: I have to reload the XMIResourceImpl-object from the
> filesystem. I don't know why, but if I create a new ResourceSetImpl, and let
> it give me a resource with the same URI as the resource that should be
> saved, the following code works fine:
>
> ResourceSet resourceSet = createXMIResourceSet();
> URI fileURI = URI.createFileURI(modelToSave.getURI().toFileString());
> Resource fileResource = resourceSet.createResource(fileURI);
> fileResource.load(Collections.EMPTY_MAP);
> HibernateResource hibResource = createHibernateResource(fileResource,
> modelName);
> hibResource.save(Collections.EMPTY_MAP);
>
>
>
> Ok...one thing I noticed in my new plugin-project: When I save the model
> (which now works fine) and then in another run, try to delete all the
> contents, I get a PropertyValueException:
>
> Caused by: org.hibernate.PropertyValueException: not-null property
> references a null or transient value: GuardSpecification.data
>
> I can post the zip-file containing the project and you can look at the
> exceptionv if you like.
>
> One last question: How can I copy a resource? For example, when I want to
> perform a "Save as"-Action, I want to give the resource a new URI, but I do
> not want to loose the old resource-contents. Is there an easy way to do
> this?
>
> Kind regards,
> Markus
>
>
>


--

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+Hibernate] TransientObjectException while saving a resourc [message #78834 is a reply to message #78822] Sat, 07 April 2007 12:44 Go to previous messageGo to next message
Markus Bischof is currently offline Markus BischofFriend
Messages: 72
Registered: July 2009
Member
Hi Marin,

> I am not sure what 'save as' means in a database contents, do you mean
> copy to another database?
I want to deepcopy a PackageImpl-object. I identify a rootPackage with it's
name, and when I perform "Save As" I want to deepcopy the rootPackage and
give it an other name. But this is not so important...

Back to the saving problem:
After I managed to save a resource from the filesystem to the database, I
loaded the resource from the database to make some changes to that resource.
Unfortunately I get a WrongClassException from the
org.hibernate.loader.Loader-class when I click on a model-element in the
GUI. The exception-message is:

Object with id: 68 was not of the specified subclass: OrganisationUnit
(loaded object was of wrong class class
de.uniAugsburg.agilPro.model.processes.impl.ActionImpl)

The GUI handles the error so that I can continue without any impact. But
when I want to save the changed resource, I get that exception again and I
can't save the resource.

I tried to recreate the exception in a small test-project, but when I load
or save that resource I do not get any exceptions.

Markus


Here are some more information about how I load the resource in my editor:
Loading a model from the database, I use a DatabaseEditorInput-Object, which
gives me the resourceUri to the model in the database. I load the resource
using the following code:

mainModelResource =
getEmfEditingDomain().getResourceSet().getResource(resourceU ri, true);

When I change that code and load the resource myself the WrongClassException
is not thrown and I can edit the resource. But then I get exceptions for all
ReferenceImpl-Objects in the model, so that I discarded that approach.
Perhaps the EmfEditingDomain does something wrong and if that is fixed, the
resource is loaded correctly and I can change the content...


Re: [Teneo+Hibernate] TransientObjectException while saving a resourc [message #78848 is a reply to message #78834] Sat, 07 April 2007 19:40 Go to previous messageGo to next message
Markus Bischof is currently offline Markus BischofFriend
Messages: 72
Registered: July 2009
Member
Hi!

I could isolate the WrongClassException with a model with 2 objects:

One RoleImpl and one ActionImpl.

I did the following steps in the GUI:
Created a new Model and added an ActionImpl. After that I added a RoleImpl.
Then I connected the elements using a ReferenceImpl. After that I could save
the model in the database, but when I reloaded it, I couldn't save it
anymore...I always get the WrongClassException...

A funny thing is, that as long as I loaded the resource from the database
BEFORE I connect the 2 items with the ReferenceImpl, I can connect them and
change the resource and the changes are saved.
But just after the reload, I can't save it anymore.

Another funny thing is, that when I manually load the resource, change the
position of e.g. the ActionImpl, and save it, everything works fine. I only
get that exception when I load the resource from the database using the code
in the editor:

mainModelResource =
getEmfEditingDomain().getResourceSet().getResource(resourceU ri, true);

Is there something wrong with the registration of the HbDataStore?

Regards,
Markus
Re: [Teneo+Hibernate] TransientObjectException while saving a resourc [message #78859 is a reply to message #78848] Sun, 08 April 2007 06:23 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Markus,
A few questions.
Can you post some sample code? I mean: what does connect the 2 items with a ReferenceImpl mean? What
is the exact error message/stack trace you get? How do you reload in the editor?

In the database: the modelelement table contains an id and a dtype column, can you use the id
(listed in the error message) to check in the modelelement table what the content of the dtype
column is?

Did you follow the exact same scenario in the manual case as in the editor case (the descriptions
differ)? In the manual scenario did you re-use the same resource for all actions?

gr. Martin

Markus Bischof wrote:
> Hi!
>
> I could isolate the WrongClassException with a model with 2 objects:
>
> One RoleImpl and one ActionImpl.
>
> I did the following steps in the GUI:
> Created a new Model and added an ActionImpl. After that I added a RoleImpl.
> Then I connected the elements using a ReferenceImpl. After that I could save
> the model in the database, but when I reloaded it, I couldn't save it
> anymore...I always get the WrongClassException...
>
> A funny thing is, that as long as I loaded the resource from the database
> BEFORE I connect the 2 items with the ReferenceImpl, I can connect them and
> change the resource and the changes are saved.
> But just after the reload, I can't save it anymore.
>
> Another funny thing is, that when I manually load the resource, change the
> position of e.g. the ActionImpl, and save it, everything works fine. I only
> get that exception when I load the resource from the database using the code
> in the editor:
>
> mainModelResource =
> getEmfEditingDomain().getResourceSet().getResource(resourceU ri, true);
>
> Is there something wrong with the registration of the HbDataStore?
>
> Regards,
> Markus
>
>


--

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+Hibernate] TransientObjectException while saving a resourc [message #78872 is a reply to message #78859] Sun, 08 April 2007 07:44 Go to previous messageGo to next message
Markus Bischof is currently offline Markus BischofFriend
Messages: 72
Registered: July 2009
Member
Hi Martin!

> A few questions.
> Can you post some sample code? I mean: what does connect the 2 items with
> a ReferenceImpl mean? What
> is the exact error message/stack trace you get? How do you reload in the
> editor?
See stacktrace.txt for the complete stacktrace. "Connecting" 2 items means,
that I have 2 elements in the GUI and I draw a line from one item to another
(in my case this is done using a ReferenceImpl-object). I don't know exactly
how the reloading is done in the editor (do you mean reloading of the
changed resource?) because I did not code that and therefore I do not know
where to look for that....I've added manualcode.txt for some samplecode
which load the test.agilpro file, saves it in the database and then loads it
again and changes the position of the action (which works fine). I that case
I manually craete the Resource, and I think that because of this it works...


> In the database: the modelelement table contains an id and a dtype column,
> can you use the id
> (listed in the error message) to check in the modelelement table what the
> content of the dtype
> column is?
The dtype is Action.


> Did you follow the exact same scenario in the manual case as in the editor
> case (the descriptions
> differ)? In the manual scenario did you re-use the same resource for all
> actions?
The difference between manual and the editor case is, that in the manual
case, I do not have a EMF-EditingDomain, so that I craete a Resourceset
myself and let it create a HibernateResource (see manualcode.txt for that).
In the editorcase I just create the URI and the I call

mainModelResource =
getEmfEditingDomain().getResourceSet().getResource(resourceU ri, true);

which creates the HibernateResource automatically. I think that there is
something wrong...

In the manual case I cannot do this, because there is no EmfEditingDomain
(at least I don't know how to get it...)

In the manual case I can load the resource and change e.g. the position. In
the editorcase I can move an item in the GUI to another location, but when I
want to save the resource, I get that error. As mentioned, I think there is
somthing wrong with the EmfEditingDomain-resource-loading...could it be that
some epackages are missing there?!

I've added the model which causes the WronClassException when it is saved in
the database and loaded through the EmfEditingDomain.

I hope this is useful!!!!

Kind regards...
Markus






Re: [Teneo+Hibernate] TransientObjectException while saving a resourc [message #79327 is a reply to message #78872] Wed, 11 April 2007 04:17 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Markus,
And what happens if you do the 'connect 2 items' scenario in the manualcode? Or does 'changing the
position' in the editor also cause the same error? (I mean it seems that the actions you try in the
editor and the manualcode are different).

Below is a piece of code from the Teneo test cases which creates an editingdomain programmatically.
Maybe you can use that to reproduce the error.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>
ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(factories);
BasicCommandStack commandStack = new BasicCommandStack();
EditingDomain editDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new
HashMap());;

// get and load the resource
final String uriStr = getResourceUri(store);
final URI uri = URI.createURI(uriStr);
Resource resource = editDomain.getResourceSet().createResource(uri);
resource.load (Collections.EMPTY_MAP);

// get contacts and person
Contacts contacts = (Contacts)resource.getContents().get(0);
Person person = (Person) contacts.getPersons().get(0);

// copy
CopyCommand cpcmd = new CopyCommand(editDomain, person, new Helper());
//(CopyCommand)CopyCommand.create(editDomain, person);
cpcmd.execute();

// get the copied person, change it and add it to the resource
Person cpPerson = (Person)cpcmd.getResult().iterator().next();
cpPerson.setName("copy");
contacts.getPersons().add(cpPerson);

// save it
resource.save(Collections.EMPTY_MAP);

// change the copy
cpPerson.setName("copy2");

// before the next save gave an error but now it works fine.
resource.save(Collections.EMPTY_MAP);
resource.unload();
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>

Markus Bischof wrote:
> Hi Martin!
>
>> A few questions.
>> Can you post some sample code? I mean: what does connect the 2 items with
>> a ReferenceImpl mean? What
>> is the exact error message/stack trace you get? How do you reload in the
>> editor?
> See stacktrace.txt for the complete stacktrace. "Connecting" 2 items means,
> that I have 2 elements in the GUI and I draw a line from one item to another
> (in my case this is done using a ReferenceImpl-object). I don't know exactly
> how the reloading is done in the editor (do you mean reloading of the
> changed resource?) because I did not code that and therefore I do not know
> where to look for that....I've added manualcode.txt for some samplecode
> which load the test.agilpro file, saves it in the database and then loads it
> again and changes the position of the action (which works fine). I that case
> I manually craete the Resource, and I think that because of this it works...
>
>
>> In the database: the modelelement table contains an id and a dtype column,
>> can you use the id
>> (listed in the error message) to check in the modelelement table what the
>> content of the dtype
>> column is?
> The dtype is Action.
>
>
>> Did you follow the exact same scenario in the manual case as in the editor
>> case (the descriptions
>> differ)? In the manual scenario did you re-use the same resource for all
>> actions?
> The difference between manual and the editor case is, that in the manual
> case, I do not have a EMF-EditingDomain, so that I craete a Resourceset
> myself and let it create a HibernateResource (see manualcode.txt for that).
> In the editorcase I just create the URI and the I call
>
> mainModelResource =
> getEmfEditingDomain().getResourceSet().getResource(resourceU ri, true);
>
> which creates the HibernateResource automatically. I think that there is
> something wrong...
>
> In the manual case I cannot do this, because there is no EmfEditingDomain
> (at least I don't know how to get it...)
>
> In the manual case I can load the resource and change e.g. the position. In
> the editorcase I can move an item in the GUI to another location, but when I
> want to save the resource, I get that error. As mentioned, I think there is
> somthing wrong with the EmfEditingDomain-resource-loading...could it be that
> some epackages are missing there?!
>
> I've added the model which causes the WronClassException when it is saved in
> the database and loaded through the EmfEditingDomain.
>
> I hope this is useful!!!!
>
> Kind regards...
> Markus
>
>
>
> package agilprotests;
>
> import java.io.IOException;
> import java.util.Collections;
> import java.util.Properties;
>
> import model.application.ApplicationPackage;
> import model.core.CorePackage;
> import model.core.impl.PackageImpl;
> import model.data.DataPackage;
> import model.events.EventsPackage;
> import model.functions.FunctionsPackage;
> import model.organisations.OrganisationsPackage;
> import model.primitiveTypes.PrimitiveTypesPackage;
> import model.processes.ProcessesPackage;
> import model.processes.impl.ActionImpl;
> import model.processes.impl.ActivityImpl;
> import model.processes.impl.ReferenceImpl;
> import model.view.Point;
> import model.view.ViewPackage;
> import model.view.impl.PointImpl;
>
> import org.eclipse.emf.common.util.URI;
> import org.eclipse.emf.ecore.EPackage;
> import org.eclipse.emf.ecore.resource.Resource;
> import org.eclipse.emf.ecore.resource.ResourceSet;
> import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
> import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
> import org.eclipse.emf.teneo.hibernate.HbDataStore;
> import org.eclipse.emf.teneo.hibernate.HbHelper;
> import org.eclipse.emf.teneo.hibernate.resource.HibernateResourceFa ctory;
> import org.hibernate.cfg.Environment;
>
> import junit.framework.TestCase;
>
> public class AgilProTests extends TestCase {
>
> private HbDataStore hbds=null;
>
> @Override
> protected void setUp() throws Exception {
> if(hbds==null)
> initHibernateStore();
> }
>
> private void initHibernateStore() {
> System.out.println("setup!");
> // Initialize the HbDataStore
> hbds = HbHelper.INSTANCE.createRegisterDataStore("agilprodb");
> hbds.setEPackages(new EPackage[]{CorePackage.eINSTANCE,
> ApplicationPackage.eINSTANCE,
> DataPackage.eINSTANCE,
> EventsPackage.eINSTANCE,
> FunctionsPackage.eINSTANCE,
> OrganisationsPackage.eINSTANCE,
> PrimitiveTypesPackage.eINSTANCE,
> ProcessesPackage.eINSTANCE,
> ViewPackage.eINSTANCE});
> hbds.setHibernateProperties(getDatabaseProperties());
> hbds.initialize();
> }
>
> private Properties getDatabaseProperties() {
>
> // generate properties
> Properties props = new Properties();
> props.setProperty(Environment.DRIVER, "com.mysql.jdbc.Driver");
> props.setProperty(Environment.USER, "root");
> props.setProperty(Environment.URL, "jdbc:mysql://127.0.0.1:3306/teneotestbase");
> props.setProperty(Environment.PASS, "root");
> props.setProperty(Environment.DIALECT, org.hibernate.dialect.MySQLInnoDBDialect.class.getName());
> props.setProperty(Environment.CURRENT_SESSION_CONTEXT_CLASS, "thread");
>
> // return result
> return props;
> }
>
> public void testClear() {
> try {
> // load standardpalette from filesystem
> ResourceSet resourceSet2 = createXMIResourceSet();
> URI fileURI = URI.createURI("test.agilpro");
> Resource fileResource = resourceSet2.createResource(fileURI);
> fileResource.load(Collections.EMPTY_MAP);
>
> // save somemodel in database
> ResourceSet resourceSet = createHibernateResourceSet();
> URI databaseURI = URI.createURI("hibernate://?dsname=agilprodb&query1=from Package where name='test'");
> Resource databaseResource = resourceSet.createResource(databaseURI);
> databaseResource.load(Collections.EMPTY_MAP);
> databaseResource.getContents().add(fileResource.getAllConten ts().next());
>
> // set rootname and save resource
> ((PackageImpl)databaseResource.getContents().get(0)).setName ( "test");
> databaseResource.save(Collections.EMPTY_MAP);
>
> // load again
> databaseResource.load(Collections.EMPTY_MAP);
>
> // pick an item
> PackageImpl root = (PackageImpl)databaseResource.getContents().get(0);
> ActivityImpl act = (ActivityImpl)root.getElements().get(0);
> ActionImpl action = (ActionImpl)act.getNodes().get(0);
> PointImpl point = (PointImpl)action.getLocation();
> point.setX(50);
> point.setY(100);
> action.setLocation(point);
> databaseResource.save(Collections.EMPTY_MAP);
> }
> catch(Exception ex) {
> ex.printStackTrace();
> assertTrue(false);
> }
> }
>
> private ResourceSet createXMIResourceSet() {
> // create resourceset
> ResourceSet resourceSet = new ResourceSetImpl();
>
> // register extension for XMI and database resources
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap()
> .put("agilpro", new XMIResourceFactoryImpl());
>
> // register epackages
> resourceSet.getPackageRegistry().put(CorePackage.eNS_URI,
> CorePackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ProcessesPackage.eNS_UR I,
> ProcessesPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ApplicationPackage.eNS_ URI,
> ApplicationPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(DataPackage.eNS_URI,
> DataPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(EventsPackage.eNS_URI,
> EventsPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(FunctionsPackage.eNS_UR I,
> FunctionsPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(OrganisationsPackage.eN S_URI,
> OrganisationsPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(PrimitiveTypesPackage.e NS_URI,
> PrimitiveTypesPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ProcessesPackage.eNS_UR I,
> ProcessesPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ViewPackage.eNS_URI,
> ViewPackage.eINSTANCE);
> return resourceSet;
> }
>
> private ResourceSet createHibernateResourceSet() {
> // create resourceset
> ResourceSet resourceSet = new ResourceSetImpl();
>
> // register extension for XMI and database resources
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap()
> .put("agilprodb", new HibernateResourceFactory());
>
> // register epackages
> resourceSet.getPackageRegistry().put(CorePackage.eNS_URI,
> CorePackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ProcessesPackage.eNS_UR I,
> ProcessesPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ApplicationPackage.eNS_ URI,
> ApplicationPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(DataPackage.eNS_URI,
> DataPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(EventsPackage.eNS_URI,
> EventsPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(FunctionsPackage.eNS_UR I,
> FunctionsPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(OrganisationsPackage.eN S_URI,
> OrganisationsPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(PrimitiveTypesPackage.e NS_URI,
> PrimitiveTypesPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ProcessesPackage.eNS_UR I,
> ProcessesPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ViewPackage.eNS_URI,
> ViewPackage.eINSTANCE);
> return resourceSet;
> }
> }
>
> org.hibernate.WrongClassException: Object with id: 16 was not of the specified subclass: OrganisationUnit (loaded object was of wrong class class de.uniAugsburg.agilPro.model.processes.impl.ActionImpl)
> at org.hibernate.loader.Loader.instanceAlreadyLoaded(Loader.jav a:1234)
> at org.hibernate.loader.Loader.getRow(Loader.java:1186)
> at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java: 568)
> at org.hibernate.loader.Loader.doQuery(Loader.java:689)
> at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyColle ctions(Loader.java:224)
> at org.hibernate.loader.Loader.loadCollection(Loader.java:1985)
> at org.hibernate.loader.collection.CollectionLoader.initialize( CollectionLoader.java:36)
> at org.hibernate.persister.collection.AbstractCollectionPersist er.initialize(AbstractCollectionPersister.java:565)
> at org.hibernate.event.def.DefaultInitializeCollectionEventList ener.onInitializeCollection(DefaultInitializeCollectionEvent Listener.java:60)
> at org.hibernate.impl.SessionImpl.initializeCollection(SessionI mpl.java:1716)
> at org.hibernate.collection.AbstractPersistentCollection.initia lize(AbstractPersistentCollection.java:344)
> at org.hibernate.collection.AbstractPersistentCollection.read(A bstractPersistentCollection.java:86)
> at org.hibernate.collection.PersistentList.toArray(PersistentLi st.java:123)
> at org.eclipse.emf.teneo.hibernate.mapping.elist.HibernatePersi stableEList.doLoad(HibernatePersistableEList.java:133)
> at org.eclipse.emf.teneo.mapping.elist.PersistableEList.load(Pe rsistableEList.java:199)
> at org.eclipse.emf.teneo.mapping.elist.PersistableEList.delegat eIsEmpty(PersistableEList.java:368)
> at org.eclipse.emf.common.util.DelegatingEList.isEmpty(Delegati ngEList.java:232)
> at de.uniAugsburg.agilPro.model.organisations.impl.RoleImpl.eIs Set(RoleImpl.java:155)
> at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eIsSet(BasicEObj ectImpl.java:818)
> at org.eclipse.emf.ecore.util.EContentsEList$FeatureIteratorImp l.hasNext(EContentsEList.java:414)
> at org.eclipse.emf.ecore.util.EObjectValidator.validate_EveryPr oxyResolves(EObjectValidator.java:328)
> at org.eclipse.emf.ecore.util.EObjectValidator.validate_EveryDe faultConstraint(EObjectValidator.java:183)
> at org.eclipse.emf.ecore.util.EObjectValidator.validate(EObject Validator.java:168)
> at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostic ian.java:127)
> at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostic ian.java:107)
> at org.eclipse.emf.teneo.resource.NonLoadingDiagnostician.doVal idateContents(NonLoadingDiagnostician.java:52)
> at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostic ian.java:130)
> at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostic ian.java:107)
> at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostic ian.java:87)
> at org.eclipse.emf.teneo.resource.StoreResource.validateObject( StoreResource.java:444)
> at org.eclipse.emf.teneo.resource.StoreResource.validateContent s(StoreResource.java:427)
> at org.eclipse.emf.teneo.resource.StoreResource.save(StoreResou rce.java:368)
> at de.uniAugsburg.agilPro.editors.AgilProEditor.doSave(AgilProE ditor.java:902)
> at org.eclipse.ui.internal.SaveableHelper$1.run(SaveableHelper. java:130)
> at org.eclipse.ui.internal.SaveableHelper$4.run(SaveableHelper. java:257)
> at org.eclipse.jface.operation.ModalContext.runInCurrentThread( ModalContext.java:369)
> at org.eclipse.jface.operation.ModalContext.run(ModalContext.ja va:313)
> at org.eclipse.jface.window.ApplicationWindow$1.run(Application Window.java:763)
> at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:67)
> at org.eclipse.jface.window.ApplicationWindow.run(ApplicationWi ndow.java:760)
> at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow. java:2283)
> at org.eclipse.ui.internal.SaveableHelper.runProgressMonitorOpe ration(SaveableHelper.java:263)
> at org.eclipse.ui.internal.SaveableHelper.runProgressMonitorOpe ration(SaveableHelper.java:243)
> at org.eclipse.ui.internal.SaveableHelper.savePart(SaveableHelp er.java:135)
> at org.eclipse.ui.internal.EditorManager.savePart(EditorManager .java:1414)
> at org.eclipse.ui.internal.WorkbenchPage.savePart(WorkbenchPage .java:2995)
> at org.eclipse.ui.internal.WorkbenchPage.saveEditor(WorkbenchPa ge.java:3008)
> at org.eclipse.ui.internal.SaveAction.run(SaveAction.java:67)
> at org.eclipse.jface.action.Action.runWithEvent(Action.java:499 )
> at org.eclipse.jface.commands.ActionHandler.execute(ActionHandl er.java:119)
> at org.eclipse.core.commands.Command.executeWithChecks(Command. java:461)
> at org.eclipse.core.commands.ParameterizedCommand.executeWithCh ecks(ParameterizedCommand.java:424)
> at org.eclipse.ui.internal.handlers.HandlerService.executeComma nd(HandlerService.java:160)
> at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeComman d(WorkbenchKeyboard.java:466)
> at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(Workben chKeyboard.java:799)
> at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEve nt(WorkbenchKeyboard.java:846)
> at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequ enceBindings(WorkbenchKeyboard.java:564)
> at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(Work benchKeyboard.java:506)
> at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter .handleEvent(WorkbenchKeyboard.java:122)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
> at org.eclipse.swt.widgets.Display.filterEvent(Display.java:982 )
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:927)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:952)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:937)
> at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:965)
> at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:961)
> at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1275)
> at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3346)
> at org.eclipse.swt.widgets.Control.windowProc(Control.java:3246 )
> at org.eclipse.swt.widgets.Display.windowProc(Display.java:4025 )
> at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
> at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:19 32)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2966)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1930)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1894)
> at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:422)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
> at de.uniAugsburg.agilPro.editors.rcp.Application.run(Applicati on.java:63)
> 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)


--

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+Hibernate] TransientObjectException while saving a resourc [message #79541 is a reply to message #79327] Thu, 12 April 2007 08:32 Go to previous messageGo to next message
Markus Bischof is currently offline Markus BischofFriend
Messages: 72
Registered: July 2009
Member
Hi Martin,

I found out, that the WrongClassException only occurs when I add a palette
the the editDomain:

protected void setEditDomain(EditDomain newEditDomain)
{
editDomain = newEditDomain;
if (editDomain instanceof GefEmfEditingDomain)
{
((GefEmfEditingDomain) editDomain)
.setEmfEditingDomain(createEmfEditingDomain());
}
editDomain.setPaletteRoot(getPaletteRoot()); // causes the error (****)
}

When I delete the setPaletteRoot-line, I can change and save the model
without the WrongClassException. I try to look deeper in the Palette-code
and see if there is something wrong...unfortunately I do not know for what I
am looking for...

Kind regards,
Markus
Re: [Teneo+Hibernate] TransientObjectException while saving a resourc [message #79619 is a reply to message #79541] Thu, 12 April 2007 11:38 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Ok, if you have a focused test case/project which replicates the issue then I can also look at it.
Have you tried to programmatically create the editing domain?

Here is a link to a post on this exception on the hibernate forum (but maybe you also found it):
http://forum.hibernate.org/viewtopic.php?t=938520&sid=2e 7dda00efe2c8b8da6fa0799800af52

gr. Martin

Markus Bischof wrote:
> Hi Martin,
>
> I found out, that the WrongClassException only occurs when I add a palette
> the the editDomain:
>
> protected void setEditDomain(EditDomain newEditDomain)
> {
> editDomain = newEditDomain;
> if (editDomain instanceof GefEmfEditingDomain)
> {
> ((GefEmfEditingDomain) editDomain)
> .setEmfEditingDomain(createEmfEditingDomain());
> }
> editDomain.setPaletteRoot(getPaletteRoot()); // causes the error (****)
> }
>
> When I delete the setPaletteRoot-line, I can change and save the model
> without the WrongClassException. I try to look deeper in the Palette-code
> and see if there is something wrong...unfortunately I do not know for what I
> am looking for...
>
> Kind regards,
> Markus
>
>


--

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
e: [Teneo+Hibernate] TransientObjectException while saving a resourc [message #79665 is a reply to message #79619] Thu, 12 April 2007 13:49 Go to previous messageGo to next message
Markus Bischof is currently offline Markus BischofFriend
Messages: 72
Registered: July 2009
Member
Hi Martin!

I've finally managed to create a test-project, where you can see the
WrongClassException! Unfortunately I had to add some javafiles and some code
from the real application, which I did not write by myself to comile the
project. I hope the code is not too confusing (e.g. I had to add the
Palette.java-file where somehow the error comes from)!

I've added some comments in the AgilProTests.java-File, too, but I will
shortly explain, what causes the error:

First you have to save the model from the filesystem in the database. For
this, you just have to run the AgilProTests-file. It should save the model
in the database (using the loadAndSaveModel()-method).

After that you have to delete (or comment) the
instance.loadAndSaveModel()-method, and use the
instance.loadAndChangeModel()-method instead (in the main-method). Now an
exception is thrown...

I also added a deleteModel()-method, which tries to delete the model. This
method also fails, when it is called alone in a run (without the method
instance.loadAndSaveModel()).

I hope you can reconstruct the exception.

As I mentioned, I found out, that somehow the palette causes the error. I
you delete the line:

editDomain.setPaletteRoot(...)

in the createEditDomain()-method, everything works fine (also the deleting
of the model!!!) Because of this, I assume that somehow the palette causes
the error...

As you will see, there is only an exception when the changing or deleting of
the Resource-contents are done within a separate run. If you call the
methods within one single run, everything works fine...

Finally, I hope you can download the file and test the project...I've had to
remove the imported libraries, because the file would be too big...how can I
send them to you?

With kind regards,
Markus Bischof



  • Attachment: agil-mod.zip
    (Size: 421.84KB, Downloaded 177 times)
Re: e: [Teneo+Hibernate] TransientObjectException while saving a resourc [message #79683 is a reply to message #79665] Thu, 12 April 2007 14:00 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Markus,
No problem I have the hibernate libraries (if you mean that) with source code and all so that makes
debugging easier. I won't have time tomorrow probably but over the weekend I will look at it.

gr. Martin

Markus Bischof wrote:
> Hi Martin!
>
> I've finally managed to create a test-project, where you can see the
> WrongClassException! Unfortunately I had to add some javafiles and some code
> from the real application, which I did not write by myself to comile the
> project. I hope the code is not too confusing (e.g. I had to add the
> Palette.java-file where somehow the error comes from)!
>
> I've added some comments in the AgilProTests.java-File, too, but I will
> shortly explain, what causes the error:
>
> First you have to save the model from the filesystem in the database. For
> this, you just have to run the AgilProTests-file. It should save the model
> in the database (using the loadAndSaveModel()-method).
>
> After that you have to delete (or comment) the
> instance.loadAndSaveModel()-method, and use the
> instance.loadAndChangeModel()-method instead (in the main-method). Now an
> exception is thrown...
>
> I also added a deleteModel()-method, which tries to delete the model. This
> method also fails, when it is called alone in a run (without the method
> instance.loadAndSaveModel()).
>
> I hope you can reconstruct the exception.
>
> As I mentioned, I found out, that somehow the palette causes the error. I
> you delete the line:
>
> editDomain.setPaletteRoot(...)
>
> in the createEditDomain()-method, everything works fine (also the deleting
> of the model!!!) Because of this, I assume that somehow the palette causes
> the error...
>
> As you will see, there is only an exception when the changing or deleting of
> the Resource-contents are done within a separate run. If you call the
> methods within one single run, everything works fine...
>
> Finally, I hope you can download the file and test the project...I've had to
> remove the imported libraries, because the file would be too big...how can I
> send them to you?
>
> With kind regards,
> Markus Bischof
>
>
>


--

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+Hibernate] TransientObjectException while saving a resourc [message #80605 is a reply to message #78872] Mon, 23 April 2007 04:10 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Markus,
I have finally had time to look at this issue. Sorry that this look longer than I promised.

This issue (at least the one in the testcase) is caused by the following association:
- the performedby efeature from role to organisationunit: this association is stored in the column:
role_performedby_e_id
- the performedby efeature from action to role: this association is stored in the column:
role_performedby_e_id

because both organisationunit and action are stored in the same table (the modelelement) this means
that when the testset is created that the action object refers to a role, then when the action is
saved the reference to role is saved in the role_performedby_e_id column. Then when the data is
loaded and the role is loaded then the system reads the organisationunits and accidently reads an
action object (because it uses the same role_performedby_e_id column) which it does not expect.

This issue occurs because accidently the name of the efeature in the role and the action have the
same name and colliding reference and the organisationunit is stored in the same table as the action.

You can solve this issue by either using a joined table inheritance mapping strategy or by adding a
JoinColumn annotation to either of the two above associations so that the two associations are not
mapped to the same column.
for example:
@JoinColumn(name="actionToRole referencedColumnName="e_id")

For a later release I'll think about a strategy to always generate unique joincolumn and jointable
names with the disadvantage of longer table/columnnames.

gr. Martin

Markus Bischof wrote:
> Hi Martin!
>
>> A few questions.
>> Can you post some sample code? I mean: what does connect the 2 items with
>> a ReferenceImpl mean? What
>> is the exact error message/stack trace you get? How do you reload in the
>> editor?
> See stacktrace.txt for the complete stacktrace. "Connecting" 2 items means,
> that I have 2 elements in the GUI and I draw a line from one item to another
> (in my case this is done using a ReferenceImpl-object). I don't know exactly
> how the reloading is done in the editor (do you mean reloading of the
> changed resource?) because I did not code that and therefore I do not know
> where to look for that....I've added manualcode.txt for some samplecode
> which load the test.agilpro file, saves it in the database and then loads it
> again and changes the position of the action (which works fine). I that case
> I manually craete the Resource, and I think that because of this it works...
>
>
>> In the database: the modelelement table contains an id and a dtype column,
>> can you use the id
>> (listed in the error message) to check in the modelelement table what the
>> content of the dtype
>> column is?
> The dtype is Action.
>
>
>> Did you follow the exact same scenario in the manual case as in the editor
>> case (the descriptions
>> differ)? In the manual scenario did you re-use the same resource for all
>> actions?
> The difference between manual and the editor case is, that in the manual
> case, I do not have a EMF-EditingDomain, so that I craete a Resourceset
> myself and let it create a HibernateResource (see manualcode.txt for that).
> In the editorcase I just create the URI and the I call
>
> mainModelResource =
> getEmfEditingDomain().getResourceSet().getResource(resourceU ri, true);
>
> which creates the HibernateResource automatically. I think that there is
> something wrong...
>
> In the manual case I cannot do this, because there is no EmfEditingDomain
> (at least I don't know how to get it...)
>
> In the manual case I can load the resource and change e.g. the position. In
> the editorcase I can move an item in the GUI to another location, but when I
> want to save the resource, I get that error. As mentioned, I think there is
> somthing wrong with the EmfEditingDomain-resource-loading...could it be that
> some epackages are missing there?!
>
> I've added the model which causes the WronClassException when it is saved in
> the database and loaded through the EmfEditingDomain.
>
> I hope this is useful!!!!
>
> Kind regards...
> Markus
>
>
>
> package agilprotests;
>
> import java.io.IOException;
> import java.util.Collections;
> import java.util.Properties;
>
> import model.application.ApplicationPackage;
> import model.core.CorePackage;
> import model.core.impl.PackageImpl;
> import model.data.DataPackage;
> import model.events.EventsPackage;
> import model.functions.FunctionsPackage;
> import model.organisations.OrganisationsPackage;
> import model.primitiveTypes.PrimitiveTypesPackage;
> import model.processes.ProcessesPackage;
> import model.processes.impl.ActionImpl;
> import model.processes.impl.ActivityImpl;
> import model.processes.impl.ReferenceImpl;
> import model.view.Point;
> import model.view.ViewPackage;
> import model.view.impl.PointImpl;
>
> import org.eclipse.emf.common.util.URI;
> import org.eclipse.emf.ecore.EPackage;
> import org.eclipse.emf.ecore.resource.Resource;
> import org.eclipse.emf.ecore.resource.ResourceSet;
> import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
> import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
> import org.eclipse.emf.teneo.hibernate.HbDataStore;
> import org.eclipse.emf.teneo.hibernate.HbHelper;
> import org.eclipse.emf.teneo.hibernate.resource.HibernateResourceFa ctory;
> import org.hibernate.cfg.Environment;
>
> import junit.framework.TestCase;
>
> public class AgilProTests extends TestCase {
>
> private HbDataStore hbds=null;
>
> @Override
> protected void setUp() throws Exception {
> if(hbds==null)
> initHibernateStore();
> }
>
> private void initHibernateStore() {
> System.out.println("setup!");
> // Initialize the HbDataStore
> hbds = HbHelper.INSTANCE.createRegisterDataStore("agilprodb");
> hbds.setEPackages(new EPackage[]{CorePackage.eINSTANCE,
> ApplicationPackage.eINSTANCE,
> DataPackage.eINSTANCE,
> EventsPackage.eINSTANCE,
> FunctionsPackage.eINSTANCE,
> OrganisationsPackage.eINSTANCE,
> PrimitiveTypesPackage.eINSTANCE,
> ProcessesPackage.eINSTANCE,
> ViewPackage.eINSTANCE});
> hbds.setHibernateProperties(getDatabaseProperties());
> hbds.initialize();
> }
>
> private Properties getDatabaseProperties() {
>
> // generate properties
> Properties props = new Properties();
> props.setProperty(Environment.DRIVER, "com.mysql.jdbc.Driver");
> props.setProperty(Environment.USER, "root");
> props.setProperty(Environment.URL, "jdbc:mysql://127.0.0.1:3306/teneotestbase");
> props.setProperty(Environment.PASS, "root");
> props.setProperty(Environment.DIALECT, org.hibernate.dialect.MySQLInnoDBDialect.class.getName());
> props.setProperty(Environment.CURRENT_SESSION_CONTEXT_CLASS, "thread");
>
> // return result
> return props;
> }
>
> public void testClear() {
> try {
> // load standardpalette from filesystem
> ResourceSet resourceSet2 = createXMIResourceSet();
> URI fileURI = URI.createURI("test.agilpro");
> Resource fileResource = resourceSet2.createResource(fileURI);
> fileResource.load(Collections.EMPTY_MAP);
>
> // save somemodel in database
> ResourceSet resourceSet = createHibernateResourceSet();
> URI databaseURI = URI.createURI("hibernate://?dsname=agilprodb&query1=from Package where name='test'");
> Resource databaseResource = resourceSet.createResource(databaseURI);
> databaseResource.load(Collections.EMPTY_MAP);
> databaseResource.getContents().add(fileResource.getAllConten ts().next());
>
> // set rootname and save resource
> ((PackageImpl)databaseResource.getContents().get(0)).setName ( "test");
> databaseResource.save(Collections.EMPTY_MAP);
>
> // load again
> databaseResource.load(Collections.EMPTY_MAP);
>
> // pick an item
> PackageImpl root = (PackageImpl)databaseResource.getContents().get(0);
> ActivityImpl act = (ActivityImpl)root.getElements().get(0);
> ActionImpl action = (ActionImpl)act.getNodes().get(0);
> PointImpl point = (PointImpl)action.getLocation();
> point.setX(50);
> point.setY(100);
> action.setLocation(point);
> databaseResource.save(Collections.EMPTY_MAP);
> }
> catch(Exception ex) {
> ex.printStackTrace();
> assertTrue(false);
> }
> }
>
> private ResourceSet createXMIResourceSet() {
> // create resourceset
> ResourceSet resourceSet = new ResourceSetImpl();
>
> // register extension for XMI and database resources
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap()
> .put("agilpro", new XMIResourceFactoryImpl());
>
> // register epackages
> resourceSet.getPackageRegistry().put(CorePackage.eNS_URI,
> CorePackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ProcessesPackage.eNS_UR I,
> ProcessesPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ApplicationPackage.eNS_ URI,
> ApplicationPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(DataPackage.eNS_URI,
> DataPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(EventsPackage.eNS_URI,
> EventsPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(FunctionsPackage.eNS_UR I,
> FunctionsPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(OrganisationsPackage.eN S_URI,
> OrganisationsPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(PrimitiveTypesPackage.e NS_URI,
> PrimitiveTypesPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ProcessesPackage.eNS_UR I,
> ProcessesPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ViewPackage.eNS_URI,
> ViewPackage.eINSTANCE);
> return resourceSet;
> }
>
> private ResourceSet createHibernateResourceSet() {
> // create resourceset
> ResourceSet resourceSet = new ResourceSetImpl();
>
> // register extension for XMI and database resources
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap()
> .put("agilprodb", new HibernateResourceFactory());
>
> // register epackages
> resourceSet.getPackageRegistry().put(CorePackage.eNS_URI,
> CorePackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ProcessesPackage.eNS_UR I,
> ProcessesPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ApplicationPackage.eNS_ URI,
> ApplicationPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(DataPackage.eNS_URI,
> DataPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(EventsPackage.eNS_URI,
> EventsPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(FunctionsPackage.eNS_UR I,
> FunctionsPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(OrganisationsPackage.eN S_URI,
> OrganisationsPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(PrimitiveTypesPackage.e NS_URI,
> PrimitiveTypesPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ProcessesPackage.eNS_UR I,
> ProcessesPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ViewPackage.eNS_URI,
> ViewPackage.eINSTANCE);
> return resourceSet;
> }
> }
>
> org.hibernate.WrongClassException: Object with id: 16 was not of the specified subclass: OrganisationUnit (loaded object was of wrong class class de.uniAugsburg.agilPro.model.processes.impl.ActionImpl)
> at org.hibernate.loader.Loader.instanceAlreadyLoaded(Loader.jav a:1234)
> at org.hibernate.loader.Loader.getRow(Loader.java:1186)
> at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java: 568)
> at org.hibernate.loader.Loader.doQuery(Loader.java:689)
> at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyColle ctions(Loader.java:224)
> at org.hibernate.loader.Loader.loadCollection(Loader.java:1985)
> at org.hibernate.loader.collection.CollectionLoader.initialize( CollectionLoader.java:36)
> at org.hibernate.persister.collection.AbstractCollectionPersist er.initialize(AbstractCollectionPersister.java:565)
> at org.hibernate.event.def.DefaultInitializeCollectionEventList ener.onInitializeCollection(DefaultInitializeCollectionEvent Listener.java:60)
> at org.hibernate.impl.SessionImpl.initializeCollection(SessionI mpl.java:1716)
> at org.hibernate.collection.AbstractPersistentCollection.initia lize(AbstractPersistentCollection.java:344)
> at org.hibernate.collection.AbstractPersistentCollection.read(A bstractPersistentCollection.java:86)
> at org.hibernate.collection.PersistentList.toArray(PersistentLi st.java:123)
> at org.eclipse.emf.teneo.hibernate.mapping.elist.HibernatePersi stableEList.doLoad(HibernatePersistableEList.java:133)
> at org.eclipse.emf.teneo.mapping.elist.PersistableEList.load(Pe rsistableEList.java:199)
> at org.eclipse.emf.teneo.mapping.elist.PersistableEList.delegat eIsEmpty(PersistableEList.java:368)
> at org.eclipse.emf.common.util.DelegatingEList.isEmpty(Delegati ngEList.java:232)
> at de.uniAugsburg.agilPro.model.organisations.impl.RoleImpl.eIs Set(RoleImpl.java:155)
> at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eIsSet(BasicEObj ectImpl.java:818)
> at org.eclipse.emf.ecore.util.EContentsEList$FeatureIteratorImp l.hasNext(EContentsEList.java:414)
> at org.eclipse.emf.ecore.util.EObjectValidator.validate_EveryPr oxyResolves(EObjectValidator.java:328)
> at org.eclipse.emf.ecore.util.EObjectValidator.validate_EveryDe faultConstraint(EObjectValidator.java:183)
> at org.eclipse.emf.ecore.util.EObjectValidator.validate(EObject Validator.java:168)
> at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostic ian.java:127)
> at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostic ian.java:107)
> at org.eclipse.emf.teneo.resource.NonLoadingDiagnostician.doVal idateContents(NonLoadingDiagnostician.java:52)
> at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostic ian.java:130)
> at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostic ian.java:107)
> at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostic ian.java:87)
> at org.eclipse.emf.teneo.resource.StoreResource.validateObject( StoreResource.java:444)
> at org.eclipse.emf.teneo.resource.StoreResource.validateContent s(StoreResource.java:427)
> at org.eclipse.emf.teneo.resource.StoreResource.save(StoreResou rce.java:368)
> at de.uniAugsburg.agilPro.editors.AgilProEditor.doSave(AgilProE ditor.java:902)
> at org.eclipse.ui.internal.SaveableHelper$1.run(SaveableHelper. java:130)
> at org.eclipse.ui.internal.SaveableHelper$4.run(SaveableHelper. java:257)
> at org.eclipse.jface.operation.ModalContext.runInCurrentThread( ModalContext.java:369)
> at org.eclipse.jface.operation.ModalContext.run(ModalContext.ja va:313)
> at org.eclipse.jface.window.ApplicationWindow$1.run(Application Window.java:763)
> at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:67)
> at org.eclipse.jface.window.ApplicationWindow.run(ApplicationWi ndow.java:760)
> at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow. java:2283)
> at org.eclipse.ui.internal.SaveableHelper.runProgressMonitorOpe ration(SaveableHelper.java:263)
> at org.eclipse.ui.internal.SaveableHelper.runProgressMonitorOpe ration(SaveableHelper.java:243)
> at org.eclipse.ui.internal.SaveableHelper.savePart(SaveableHelp er.java:135)
> at org.eclipse.ui.internal.EditorManager.savePart(EditorManager .java:1414)
> at org.eclipse.ui.internal.WorkbenchPage.savePart(WorkbenchPage .java:2995)
> at org.eclipse.ui.internal.WorkbenchPage.saveEditor(WorkbenchPa ge.java:3008)
> at org.eclipse.ui.internal.SaveAction.run(SaveAction.java:67)
> at org.eclipse.jface.action.Action.runWithEvent(Action.java:499 )
> at org.eclipse.jface.commands.ActionHandler.execute(ActionHandl er.java:119)
> at org.eclipse.core.commands.Command.executeWithChecks(Command. java:461)
> at org.eclipse.core.commands.ParameterizedCommand.executeWithCh ecks(ParameterizedCommand.java:424)
> at org.eclipse.ui.internal.handlers.HandlerService.executeComma nd(HandlerService.java:160)
> at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeComman d(WorkbenchKeyboard.java:466)
> at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(Workben chKeyboard.java:799)
> at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEve nt(WorkbenchKeyboard.java:846)
> at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequ enceBindings(WorkbenchKeyboard.java:564)
> at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(Work benchKeyboard.java:506)
> at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter .handleEvent(WorkbenchKeyboard.java:122)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
> at org.eclipse.swt.widgets.Display.filterEvent(Display.java:982 )
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:927)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:952)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:937)
> at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:965)
> at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:961)
> at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1275)
> at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3346)
> at org.eclipse.swt.widgets.Control.windowProc(Control.java:3246 )
> at org.eclipse.swt.widgets.Display.windowProc(Display.java:4025 )
> at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
> at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:19 32)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2966)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1930)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1894)
> at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:422)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
> at de.uniAugsburg.agilPro.editors.rcp.Application.run(Applicati on.java:63)
> 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)


--

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+Hibernate] TransientObjectException while saving a resourc [message #80725 is a reply to message #80605] Mon, 23 April 2007 18:17 Go to previous messageGo to next message
Markus Bischof is currently offline Markus BischofFriend
Messages: 72
Registered: July 2009
Member
Hi Martin!

Thanks for looking at my issue...

I tried to create a joined-subclass inheritance using the "Teneo->Generate
EMF - Hibernate OR Mapping (joind-subclass)"-menu command. I placed the
generated hibernate.hbm.xml-file in my "src" folder.
Unfortunately the method hbdatastore.getMappingXML() returns the "old"
(superclass-) mapping. Where does the hbdatastore get that mapping-xml from
(there is no file which contains that), and how can I try the new
joined-subclass xml-mapping?

gr.
Markus
Re: [Teneo+Hibernate] TransientObjectException while saving a resourc [message #80746 is a reply to message #80725] Mon, 23 April 2007 19:15 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Markus,
Teneo creates a mapping when the datastore is initialized (unless you tell the datastore to use a
hbm file in the classpath (see the options)). In practice I would use this auto-generation instead
of generating a mapping through the menu option. The mapping generation through the datastore can be
influenced by annotations and many different options (passed through the setPersistenceProperties
method):
http://www.elver.org/hibernate/options.html

one of the options influences the inheritance mapping strategy.

gr. Martin


Markus Bischof wrote:
> Hi Martin!
>
> Thanks for looking at my issue...
>
> I tried to create a joined-subclass inheritance using the "Teneo->Generate
> EMF - Hibernate OR Mapping (joind-subclass)"-menu command. I placed the
> generated hibernate.hbm.xml-file in my "src" folder.
> Unfortunately the method hbdatastore.getMappingXML() returns the "old"
> (superclass-) mapping. Where does the hbdatastore get that mapping-xml from
> (there is no file which contains that), and how can I try the new
> joined-subclass xml-mapping?
>
> gr.
> Markus
>
>


--

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+Hibernate] TransientObjectException while saving a resourc [message #80811 is a reply to message #80746] Tue, 24 April 2007 07:54 Go to previous messageGo to next message
Markus Bischof is currently offline Markus BischofFriend
Messages: 72
Registered: July 2009
Member
Hi Martin!

Ok, I changed the inheritancemapping-strategy and now the testmodel can be
saved.

But with that strategy, some bigger model throws an

java.sql.BatchUpdateException: Cannot add or update a child row: a foreign
key constraint fails (`teneotestbase/activityedge`, CONSTRAINT
`FK611D414C5DEE9828` FOREIGN KEY (`activityedge_source_e_id`) REFERENCES
`structuredactivitynode` (`scope_e_id`))

I attached the project and the model for which that exception occurs...if
you find some time, you may want to look at it.

Markus


  • Attachment: agil-mod.zip
    (Size: 423.88KB, Downloaded 178 times)
Re: [Teneo+Hibernate] TransientObjectException while saving a resourc [message #80821 is a reply to message #80811] Tue, 24 April 2007 08:10 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Markus,
Yes, I am fairly busy so it would be maybe quicker if you do some searching yourselve. Either the
reference (from activityedge.source to structuredactivitynode) is not set while it is mandatory or
it is set but the structuredactivitynode does not exist yet in the db.

If you use mysql you can do show innodb status in the mysql command line to get the a message on
what failed. Also placing a break point in where hibernate throws the catches/rethrows the exception
should allow you to get more information.

gr. Martin

Markus Bischof wrote:
> Hi Martin!
>
> Ok, I changed the inheritancemapping-strategy and now the testmodel can be
> saved.
>
> But with that strategy, some bigger model throws an
>
> java.sql.BatchUpdateException: Cannot add or update a child row: a foreign
> key constraint fails (`teneotestbase/activityedge`, CONSTRAINT
> `FK611D414C5DEE9828` FOREIGN KEY (`activityedge_source_e_id`) REFERENCES
> `structuredactivitynode` (`scope_e_id`))
>
> I attached the project and the model for which that exception occurs...if
> you find some time, you may want to look at it.
>
> Markus
>
>


--

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+Hibernate] TransientObjectException while saving a resourc [message #604408 is a reply to message #78581] Fri, 06 April 2007 07:07 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Markus,
This can be related to the cascade setting on an association. Hb walks the associations, the order
in which objects in the association chain are saved is important. Can you see which association (and
its owning object) is refering to ReferenceEdge? And what does the hbm mapping of this association
look like (the hbmmapping can be retrieved from the hbdatastore using getMappingXML())?

Can you also post the complete stacktrace?

gr. Martin

Markus Bischof wrote:
> Hi!
>
> I have a problem saving a resource which was loaded from the filesystem
> as a XMIResourceImpl-Object in the database. I tried the following code
> for small models and it worked fine (There is probably a much better and
> simpler solution for this!)
>
> hibernateResource.getContents().add(xmiResourceImplObject.ge tAllContents().next());
> hibResource.save(Collections.EMPTY_MAP);
>
> (Assuming that a resource only contains one root-object).
>
> But now I having trouble saving a bigger model. I get a
> HbMapperException which is caused by a TransientObjectException (at
> least eclipse tells me that) with the message:
>
> "object references an unsaved transient instance - save the transient
> instance before flushing: ReferenceEdge"
> So how can I save the "transient instance"?
>
> Regards,
> Markus Bischof


--

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+Hibernate] TransientObjectException while saving a resourc [message #604416 is a reply to message #78625] Fri, 06 April 2007 09:07 Go to previous message
Markus Bischof is currently offline Markus BischofFriend
Messages: 72
Registered: July 2009
Member
Hi Martin!

I've attached the stacktrace and the mapping.xml, which I get when I call
getMappingXML() on the HbDataStore. I also attached the model which causes
the error.

I will post in a few hours which association is refering to
ReferenceEdge...I must first attach the Hibernate-sources to eclipse. I hope
I find that association, but perhaps the mapping.xml and the model give some
first information!

The exception is thrown in the class HibernateResource at line 349:

// now flush everythingif (!hasSessionController) {
mySessionWrapper.flush();
}

Regards,
Markus




Re: [Teneo+Hibernate] TransientObjectException while saving a resourc [message #604420 is a reply to message #78655] Fri, 06 April 2007 11:04 Go to previous message
Markus Bischof is currently offline Markus BischofFriend
Messages: 72
Registered: July 2009
Member
Ok...I hope I have the correct one:

I went through the code and I found out, that the flush-method fails (not
the save-method) in the HibernateResource-object

Line 349: mySessionWrapper.flush();

Then in the flush()-method of the SessionImpl-class, the onFlush()-method of
a DefaultFlushEventListener-class is called, which calls a
performExecutions(...)-method of the AbstractFlushingEventListener.

Line 27: performExecutions(source);

This method calls the method executeActions() of the ActionQueue-class

Line 298: session.getActionQueue().executeActions();

which calls some executeActions(...)-methods, where the
executeActions(collectionCreations)-method fails!

Line 143: executeActions( collectionCreations );

This operation fails for the 141th item in the collectionCreations-list,
which has the collectionRole "Activity.referenceEdges".

I've attached a picture of the variables-view.

How can I give you more information??!?! I guess this is not exactly what
you ment...

Regards,
Markus


  • Attachment: error.JPG
    (Size: 18.44KB, Downloaded 119 times)
Re: [Teneo+Hibernate] TransientObjectException while saving a resourc [message #604424 is a reply to message #78672] Fri, 06 April 2007 13:57 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Can you set a breakpoint and then check which many-to-one (of which class/entity) is handled by the
ManyToOneType (method call to nullSafeSet()) in the stack trace? If you set the breakpoint where
the exception is thrown you can go back in the stacktrace and inspect the members there.

gr. Martin

Markus Bischof wrote:
> Ok...I hope I have the correct one:
>
> I went through the code and I found out, that the flush-method fails (not
> the save-method) in the HibernateResource-object
>
> Line 349: mySessionWrapper.flush();
>
> Then in the flush()-method of the SessionImpl-class, the onFlush()-method of
> a DefaultFlushEventListener-class is called, which calls a
> performExecutions(...)-method of the AbstractFlushingEventListener.
>
> Line 27: performExecutions(source);
>
> This method calls the method executeActions() of the ActionQueue-class
>
> Line 298: session.getActionQueue().executeActions();
>
> which calls some executeActions(...)-methods, where the
> executeActions(collectionCreations)-method fails!
>
> Line 143: executeActions( collectionCreations );
>
> This operation fails for the 141th item in the collectionCreations-list,
> which has the collectionRole "Activity.referenceEdges".
>
> I've attached a picture of the variables-view.
>
> How can I give you more information??!?! I guess this is not exactly what
> you ment...
>
> Regards,
> Markus
>
>
>


--

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+Hibernate] TransientObjectException while saving a resourc [message #604427 is a reply to message #78688] Fri, 06 April 2007 15:06 Go to previous message
Markus Bischof is currently offline Markus BischofFriend
Messages: 72
Registered: July 2009
Member
Ok...

the owner should be an ActivityImpl and the many-to-one should be the
referenceEdges. Here's the mapping code for that one (from the
hibernate.hbm.xml file):

<subclass entity-name="Activity" abstract="false" lazy="false"
extends="PackageableElement" discriminator-value="Activity">
.....
<list name="referenceEdges" lazy="true" cascade="all,delete-orphan">
<key update="true">
<column name="`activity_referenceedges_e_id`" not-null="false"
unique="false"/>
</key>
<list-index column="`activity_referenceedges_idx`"/>
<one-to-many entity-name="ReferenceEdge"/>
</list>
.....
</subclass>

I think that's the collectionRole I mentioned earlier. The collection itself
contains some ReferenceEdgeImpl-objects.
But I did not see a method call to nullSafeSet() in the stacktrace after the
exception. I just have the calls:

HibernateResource(StoreResource).save(...)
HibernateResource.saveResource(...)
HbSessionWrapper.flush()
SessionImpl.flush()
DefaultFlushListener.onFlush(...)
DefaultFlushEventListener(AbstractFlushingEventListener).per formExecutions(...)


Markus
Re: [Teneo+Hibernate] TransientObjectException while saving a resourc [message #604430 is a reply to message #78703] Fri, 06 April 2007 15:16 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
The part of the mapping file you showed here contains the one-to-many (the other side of the
association probably), so not the many-to-one.

I mean this part of the stacktrace (see the fourth line from the top):
Caused by: org.hibernate.TransientObjectException: object references an unsaved transient instance -
save the transient instance before flushing: ReferenceEdge
at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUns aved(ForeignKeys.java:219)
at org.hibernate.type.EntityType.getIdentifier(EntityType.java: 397)
at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.j ava:78)
at
org.hibernate.persister.collection.AbstractCollectionPersist er.writeElement(AbstractCollectionPersister.java:755)


gr. Martin

Markus Bischof wrote:
> Ok...
>
> the owner should be an ActivityImpl and the many-to-one should be the
> referenceEdges. Here's the mapping code for that one (from the
> hibernate.hbm.xml file):
>
> <subclass entity-name="Activity" abstract="false" lazy="false"
> extends="PackageableElement" discriminator-value="Activity">
> .....
> <list name="referenceEdges" lazy="true" cascade="all,delete-orphan">
> <key update="true">
> <column name="`activity_referenceedges_e_id`" not-null="false"
> unique="false"/>
> </key>
> <list-index column="`activity_referenceedges_idx`"/>
> <one-to-many entity-name="ReferenceEdge"/>
> </list>
> .....
> </subclass>
>
> I think that's the collectionRole I mentioned earlier. The collection itself
> contains some ReferenceEdgeImpl-objects.
> But I did not see a method call to nullSafeSet() in the stacktrace after the
> exception. I just have the calls:
>
> HibernateResource(StoreResource).save(...)
> HibernateResource.saveResource(...)
> HbSessionWrapper.flush()
> SessionImpl.flush()
> DefaultFlushListener.onFlush(...)
> DefaultFlushEventListener(AbstractFlushingEventListener).per formExecutions(...)
>
>
> Markus
>
>


--

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+Hibernate] TransientObjectException while saving a resourc [message #604434 is a reply to message #78688] Fri, 06 April 2007 16:17 Go to previous message
Markus Bischof is currently offline Markus BischofFriend
Messages: 72
Registered: July 2009
Member
Ok, now I think that should be the right one:

"ReferenceEdge" should be the many-to-one-type which is handled by the
ManyToOneType (is was named associatedEntityName).

The writeElement-method works fine for the first 9 ReferenceEdgeImpl-Objects
in the list, but the exception is raised when the writeElement-method is
called for the 10th element.

Markus
Re: [Teneo+Hibernate] TransientObjectException while saving a resourc [message #604456 is a reply to message #78717] Sat, 07 April 2007 08:24 Go to previous message
Markus Bischof is currently offline Markus BischofFriend
Messages: 72
Registered: July 2009
Member
Hi Martin,

I created a new plugin project like Michael to show you the error. But the
weird thing is that the model could be saved. There was no
TransientObjectException!

After that I tried to copy the code 1:1 back to my original model. The
important thing was: I have to reload the XMIResourceImpl-object from the
filesystem. I don't know why, but if I create a new ResourceSetImpl, and let
it give me a resource with the same URI as the resource that should be
saved, the following code works fine:

ResourceSet resourceSet = createXMIResourceSet();
URI fileURI = URI.createFileURI(modelToSave.getURI().toFileString());
Resource fileResource = resourceSet.createResource(fileURI);
fileResource.load(Collections.EMPTY_MAP);
HibernateResource hibResource = createHibernateResource(fileResource,
modelName);
hibResource.save(Collections.EMPTY_MAP);



Ok...one thing I noticed in my new plugin-project: When I save the model
(which now works fine) and then in another run, try to delete all the
contents, I get a PropertyValueException:

Caused by: org.hibernate.PropertyValueException: not-null property
references a null or transient value: GuardSpecification.data

I can post the zip-file containing the project and you can look at the
exceptionv if you like.

One last question: How can I copy a resource? For example, when I want to
perform a "Save as"-Action, I want to give the resource a new URI, but I do
not want to loose the old resource-contents. Is there an easy way to do
this?

Kind regards,
Markus
Re: [Teneo+Hibernate] TransientObjectException while saving a resourc [message #604459 is a reply to message #78807] Sat, 07 April 2007 09:36 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Markus,
It is hard to guess why it works now and failed earlier. This type of exception is hard to debug. It
would be easiest for me if you can send me a project zip which fails with preferably a (very) simple
dataset. Then I'll look at it further.

Why the delete action fails with a PropertyValueException I am not sure. Maybe a reference is
cleared because the refered-to object is deleted and the exception is thrown before the referer is
deleted.

I am not sure what 'save as' means in a database contents, do you mean copy to another database?
Regarding the contents of the old resource, if you don't save the resource then the removal of its
content (move contents to another resource) is not persisted to the database.

gr. Martin

Markus Bischof wrote:
> Hi Martin,
>
> I created a new plugin project like Michael to show you the error. But the
> weird thing is that the model could be saved. There was no
> TransientObjectException!
>
> After that I tried to copy the code 1:1 back to my original model. The
> important thing was: I have to reload the XMIResourceImpl-object from the
> filesystem. I don't know why, but if I create a new ResourceSetImpl, and let
> it give me a resource with the same URI as the resource that should be
> saved, the following code works fine:
>
> ResourceSet resourceSet = createXMIResourceSet();
> URI fileURI = URI.createFileURI(modelToSave.getURI().toFileString());
> Resource fileResource = resourceSet.createResource(fileURI);
> fileResource.load(Collections.EMPTY_MAP);
> HibernateResource hibResource = createHibernateResource(fileResource,
> modelName);
> hibResource.save(Collections.EMPTY_MAP);
>
>
>
> Ok...one thing I noticed in my new plugin-project: When I save the model
> (which now works fine) and then in another run, try to delete all the
> contents, I get a PropertyValueException:
>
> Caused by: org.hibernate.PropertyValueException: not-null property
> references a null or transient value: GuardSpecification.data
>
> I can post the zip-file containing the project and you can look at the
> exceptionv if you like.
>
> One last question: How can I copy a resource? For example, when I want to
> perform a "Save as"-Action, I want to give the resource a new URI, but I do
> not want to loose the old resource-contents. Is there an easy way to do
> this?
>
> Kind regards,
> Markus
>
>
>


--

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+Hibernate] TransientObjectException while saving a resourc [message #604463 is a reply to message #78822] Sat, 07 April 2007 12:44 Go to previous message
Markus Bischof is currently offline Markus BischofFriend
Messages: 72
Registered: July 2009
Member
Hi Marin,

> I am not sure what 'save as' means in a database contents, do you mean
> copy to another database?
I want to deepcopy a PackageImpl-object. I identify a rootPackage with it's
name, and when I perform "Save As" I want to deepcopy the rootPackage and
give it an other name. But this is not so important...

Back to the saving problem:
After I managed to save a resource from the filesystem to the database, I
loaded the resource from the database to make some changes to that resource.
Unfortunately I get a WrongClassException from the
org.hibernate.loader.Loader-class when I click on a model-element in the
GUI. The exception-message is:

Object with id: 68 was not of the specified subclass: OrganisationUnit
(loaded object was of wrong class class
de.uniAugsburg.agilPro.model.processes.impl.ActionImpl)

The GUI handles the error so that I can continue without any impact. But
when I want to save the changed resource, I get that exception again and I
can't save the resource.

I tried to recreate the exception in a small test-project, but when I load
or save that resource I do not get any exceptions.

Markus


Here are some more information about how I load the resource in my editor:
Loading a model from the database, I use a DatabaseEditorInput-Object, which
gives me the resourceUri to the model in the database. I load the resource
using the following code:

mainModelResource =
getEmfEditingDomain().getResourceSet().getResource(resourceU ri, true);

When I change that code and load the resource myself the WrongClassException
is not thrown and I can edit the resource. But then I get exceptions for all
ReferenceImpl-Objects in the model, so that I discarded that approach.
Perhaps the EmfEditingDomain does something wrong and if that is fixed, the
resource is loaded correctly and I can change the content...


Re: [Teneo+Hibernate] TransientObjectException while saving a resourc [message #604468 is a reply to message #78834] Sat, 07 April 2007 19:40 Go to previous message
Markus Bischof is currently offline Markus BischofFriend
Messages: 72
Registered: July 2009
Member
Hi!

I could isolate the WrongClassException with a model with 2 objects:

One RoleImpl and one ActionImpl.

I did the following steps in the GUI:
Created a new Model and added an ActionImpl. After that I added a RoleImpl.
Then I connected the elements using a ReferenceImpl. After that I could save
the model in the database, but when I reloaded it, I couldn't save it
anymore...I always get the WrongClassException...

A funny thing is, that as long as I loaded the resource from the database
BEFORE I connect the 2 items with the ReferenceImpl, I can connect them and
change the resource and the changes are saved.
But just after the reload, I can't save it anymore.

Another funny thing is, that when I manually load the resource, change the
position of e.g. the ActionImpl, and save it, everything works fine. I only
get that exception when I load the resource from the database using the code
in the editor:

mainModelResource =
getEmfEditingDomain().getResourceSet().getResource(resourceU ri, true);

Is there something wrong with the registration of the HbDataStore?

Regards,
Markus
Re: [Teneo+Hibernate] TransientObjectException while saving a resourc [message #604471 is a reply to message #78848] Sun, 08 April 2007 06:23 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Markus,
A few questions.
Can you post some sample code? I mean: what does connect the 2 items with a ReferenceImpl mean? What
is the exact error message/stack trace you get? How do you reload in the editor?

In the database: the modelelement table contains an id and a dtype column, can you use the id
(listed in the error message) to check in the modelelement table what the content of the dtype
column is?

Did you follow the exact same scenario in the manual case as in the editor case (the descriptions
differ)? In the manual scenario did you re-use the same resource for all actions?

gr. Martin

Markus Bischof wrote:
> Hi!
>
> I could isolate the WrongClassException with a model with 2 objects:
>
> One RoleImpl and one ActionImpl.
>
> I did the following steps in the GUI:
> Created a new Model and added an ActionImpl. After that I added a RoleImpl.
> Then I connected the elements using a ReferenceImpl. After that I could save
> the model in the database, but when I reloaded it, I couldn't save it
> anymore...I always get the WrongClassException...
>
> A funny thing is, that as long as I loaded the resource from the database
> BEFORE I connect the 2 items with the ReferenceImpl, I can connect them and
> change the resource and the changes are saved.
> But just after the reload, I can't save it anymore.
>
> Another funny thing is, that when I manually load the resource, change the
> position of e.g. the ActionImpl, and save it, everything works fine. I only
> get that exception when I load the resource from the database using the code
> in the editor:
>
> mainModelResource =
> getEmfEditingDomain().getResourceSet().getResource(resourceU ri, true);
>
> Is there something wrong with the registration of the HbDataStore?
>
> Regards,
> Markus
>
>


--

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+Hibernate] TransientObjectException while saving a resourc [message #604474 is a reply to message #78859] Sun, 08 April 2007 07:44 Go to previous message
Markus Bischof is currently offline Markus BischofFriend
Messages: 72
Registered: July 2009
Member
Hi Martin!

> A few questions.
> Can you post some sample code? I mean: what does connect the 2 items with
> a ReferenceImpl mean? What
> is the exact error message/stack trace you get? How do you reload in the
> editor?
See stacktrace.txt for the complete stacktrace. "Connecting" 2 items means,
that I have 2 elements in the GUI and I draw a line from one item to another
(in my case this is done using a ReferenceImpl-object). I don't know exactly
how the reloading is done in the editor (do you mean reloading of the
changed resource?) because I did not code that and therefore I do not know
where to look for that....I've added manualcode.txt for some samplecode
which load the test.agilpro file, saves it in the database and then loads it
again and changes the position of the action (which works fine). I that case
I manually craete the Resource, and I think that because of this it works...


> In the database: the modelelement table contains an id and a dtype column,
> can you use the id
> (listed in the error message) to check in the modelelement table what the
> content of the dtype
> column is?
The dtype is Action.


> Did you follow the exact same scenario in the manual case as in the editor
> case (the descriptions
> differ)? In the manual scenario did you re-use the same resource for all
> actions?
The difference between manual and the editor case is, that in the manual
case, I do not have a EMF-EditingDomain, so that I craete a Resourceset
myself and let it create a HibernateResource (see manualcode.txt for that).
In the editorcase I just create the URI and the I call

mainModelResource =
getEmfEditingDomain().getResourceSet().getResource(resourceU ri, true);

which creates the HibernateResource automatically. I think that there is
something wrong...

In the manual case I cannot do this, because there is no EmfEditingDomain
(at least I don't know how to get it...)

In the manual case I can load the resource and change e.g. the position. In
the editorcase I can move an item in the GUI to another location, but when I
want to save the resource, I get that error. As mentioned, I think there is
somthing wrong with the EmfEditingDomain-resource-loading...could it be that
some epackages are missing there?!

I've added the model which causes the WronClassException when it is saved in
the database and loaded through the EmfEditingDomain.

I hope this is useful!!!!

Kind regards...
Markus






Re: [Teneo+Hibernate] TransientObjectException while saving a resourc [message #604604 is a reply to message #78872] Wed, 11 April 2007 04:17 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Markus,
And what happens if you do the 'connect 2 items' scenario in the manualcode? Or does 'changing the
position' in the editor also cause the same error? (I mean it seems that the actions you try in the
editor and the manualcode are different).

Below is a piece of code from the Teneo test cases which creates an editingdomain programmatically.
Maybe you can use that to reproduce the error.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>
ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(factories);
BasicCommandStack commandStack = new BasicCommandStack();
EditingDomain editDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new
HashMap());;

// get and load the resource
final String uriStr = getResourceUri(store);
final URI uri = URI.createURI(uriStr);
Resource resource = editDomain.getResourceSet().createResource(uri);
resource.load (Collections.EMPTY_MAP);

// get contacts and person
Contacts contacts = (Contacts)resource.getContents().get(0);
Person person = (Person) contacts.getPersons().get(0);

// copy
CopyCommand cpcmd = new CopyCommand(editDomain, person, new Helper());
//(CopyCommand)CopyCommand.create(editDomain, person);
cpcmd.execute();

// get the copied person, change it and add it to the resource
Person cpPerson = (Person)cpcmd.getResult().iterator().next();
cpPerson.setName("copy");
contacts.getPersons().add(cpPerson);

// save it
resource.save(Collections.EMPTY_MAP);

// change the copy
cpPerson.setName("copy2");

// before the next save gave an error but now it works fine.
resource.save(Collections.EMPTY_MAP);
resource.unload();
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>

Markus Bischof wrote:
> Hi Martin!
>
>> A few questions.
>> Can you post some sample code? I mean: what does connect the 2 items with
>> a ReferenceImpl mean? What
>> is the exact error message/stack trace you get? How do you reload in the
>> editor?
> See stacktrace.txt for the complete stacktrace. "Connecting" 2 items means,
> that I have 2 elements in the GUI and I draw a line from one item to another
> (in my case this is done using a ReferenceImpl-object). I don't know exactly
> how the reloading is done in the editor (do you mean reloading of the
> changed resource?) because I did not code that and therefore I do not know
> where to look for that....I've added manualcode.txt for some samplecode
> which load the test.agilpro file, saves it in the database and then loads it
> again and changes the position of the action (which works fine). I that case
> I manually craete the Resource, and I think that because of this it works...
>
>
>> In the database: the modelelement table contains an id and a dtype column,
>> can you use the id
>> (listed in the error message) to check in the modelelement table what the
>> content of the dtype
>> column is?
> The dtype is Action.
>
>
>> Did you follow the exact same scenario in the manual case as in the editor
>> case (the descriptions
>> differ)? In the manual scenario did you re-use the same resource for all
>> actions?
> The difference between manual and the editor case is, that in the manual
> case, I do not have a EMF-EditingDomain, so that I craete a Resourceset
> myself and let it create a HibernateResource (see manualcode.txt for that).
> In the editorcase I just create the URI and the I call
>
> mainModelResource =
> getEmfEditingDomain().getResourceSet().getResource(resourceU ri, true);
>
> which creates the HibernateResource automatically. I think that there is
> something wrong...
>
> In the manual case I cannot do this, because there is no EmfEditingDomain
> (at least I don't know how to get it...)
>
> In the manual case I can load the resource and change e.g. the position. In
> the editorcase I can move an item in the GUI to another location, but when I
> want to save the resource, I get that error. As mentioned, I think there is
> somthing wrong with the EmfEditingDomain-resource-loading...could it be that
> some epackages are missing there?!
>
> I've added the model which causes the WronClassException when it is saved in
> the database and loaded through the EmfEditingDomain.
>
> I hope this is useful!!!!
>
> Kind regards...
> Markus
>
>
>
> package agilprotests;
>
> import java.io.IOException;
> import java.util.Collections;
> import java.util.Properties;
>
> import model.application.ApplicationPackage;
> import model.core.CorePackage;
> import model.core.impl.PackageImpl;
> import model.data.DataPackage;
> import model.events.EventsPackage;
> import model.functions.FunctionsPackage;
> import model.organisations.OrganisationsPackage;
> import model.primitiveTypes.PrimitiveTypesPackage;
> import model.processes.ProcessesPackage;
> import model.processes.impl.ActionImpl;
> import model.processes.impl.ActivityImpl;
> import model.processes.impl.ReferenceImpl;
> import model.view.Point;
> import model.view.ViewPackage;
> import model.view.impl.PointImpl;
>
> import org.eclipse.emf.common.util.URI;
> import org.eclipse.emf.ecore.EPackage;
> import org.eclipse.emf.ecore.resource.Resource;
> import org.eclipse.emf.ecore.resource.ResourceSet;
> import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
> import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
> import org.eclipse.emf.teneo.hibernate.HbDataStore;
> import org.eclipse.emf.teneo.hibernate.HbHelper;
> import org.eclipse.emf.teneo.hibernate.resource.HibernateResourceFa ctory;
> import org.hibernate.cfg.Environment;
>
> import junit.framework.TestCase;
>
> public class AgilProTests extends TestCase {
>
> private HbDataStore hbds=null;
>
> @Override
> protected void setUp() throws Exception {
> if(hbds==null)
> initHibernateStore();
> }
>
> private void initHibernateStore() {
> System.out.println("setup!");
> // Initialize the HbDataStore
> hbds = HbHelper.INSTANCE.createRegisterDataStore("agilprodb");
> hbds.setEPackages(new EPackage[]{CorePackage.eINSTANCE,
> ApplicationPackage.eINSTANCE,
> DataPackage.eINSTANCE,
> EventsPackage.eINSTANCE,
> FunctionsPackage.eINSTANCE,
> OrganisationsPackage.eINSTANCE,
> PrimitiveTypesPackage.eINSTANCE,
> ProcessesPackage.eINSTANCE,
> ViewPackage.eINSTANCE});
> hbds.setHibernateProperties(getDatabaseProperties());
> hbds.initialize();
> }
>
> private Properties getDatabaseProperties() {
>
> // generate properties
> Properties props = new Properties();
> props.setProperty(Environment.DRIVER, "com.mysql.jdbc.Driver");
> props.setProperty(Environment.USER, "root");
> props.setProperty(Environment.URL, "jdbc:mysql://127.0.0.1:3306/teneotestbase");
> props.setProperty(Environment.PASS, "root");
> props.setProperty(Environment.DIALECT, org.hibernate.dialect.MySQLInnoDBDialect.class.getName());
> props.setProperty(Environment.CURRENT_SESSION_CONTEXT_CLASS, "thread");
>
> // return result
> return props;
> }
>
> public void testClear() {
> try {
> // load standardpalette from filesystem
> ResourceSet resourceSet2 = createXMIResourceSet();
> URI fileURI = URI.createURI("test.agilpro");
> Resource fileResource = resourceSet2.createResource(fileURI);
> fileResource.load(Collections.EMPTY_MAP);
>
> // save somemodel in database
> ResourceSet resourceSet = createHibernateResourceSet();
> URI databaseURI = URI.createURI("hibernate://?dsname=agilprodb&query1=from Package where name='test'");
> Resource databaseResource = resourceSet.createResource(databaseURI);
> databaseResource.load(Collections.EMPTY_MAP);
> databaseResource.getContents().add(fileResource.getAllConten ts().next());
>
> // set rootname and save resource
> ((PackageImpl)databaseResource.getContents().get(0)).setName ( "test");
> databaseResource.save(Collections.EMPTY_MAP);
>
> // load again
> databaseResource.load(Collections.EMPTY_MAP);
>
> // pick an item
> PackageImpl root = (PackageImpl)databaseResource.getContents().get(0);
> ActivityImpl act = (ActivityImpl)root.getElements().get(0);
> ActionImpl action = (ActionImpl)act.getNodes().get(0);
> PointImpl point = (PointImpl)action.getLocation();
> point.setX(50);
> point.setY(100);
> action.setLocation(point);
> databaseResource.save(Collections.EMPTY_MAP);
> }
> catch(Exception ex) {
> ex.printStackTrace();
> assertTrue(false);
> }
> }
>
> private ResourceSet createXMIResourceSet() {
> // create resourceset
> ResourceSet resourceSet = new ResourceSetImpl();
>
> // register extension for XMI and database resources
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap()
> .put("agilpro", new XMIResourceFactoryImpl());
>
> // register epackages
> resourceSet.getPackageRegistry().put(CorePackage.eNS_URI,
> CorePackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ProcessesPackage.eNS_UR I,
> ProcessesPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ApplicationPackage.eNS_ URI,
> ApplicationPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(DataPackage.eNS_URI,
> DataPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(EventsPackage.eNS_URI,
> EventsPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(FunctionsPackage.eNS_UR I,
> FunctionsPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(OrganisationsPackage.eN S_URI,
> OrganisationsPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(PrimitiveTypesPackage.e NS_URI,
> PrimitiveTypesPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ProcessesPackage.eNS_UR I,
> ProcessesPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ViewPackage.eNS_URI,
> ViewPackage.eINSTANCE);
> return resourceSet;
> }
>
> private ResourceSet createHibernateResourceSet() {
> // create resourceset
> ResourceSet resourceSet = new ResourceSetImpl();
>
> // register extension for XMI and database resources
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap()
> .put("agilprodb", new HibernateResourceFactory());
>
> // register epackages
> resourceSet.getPackageRegistry().put(CorePackage.eNS_URI,
> CorePackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ProcessesPackage.eNS_UR I,
> ProcessesPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ApplicationPackage.eNS_ URI,
> ApplicationPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(DataPackage.eNS_URI,
> DataPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(EventsPackage.eNS_URI,
> EventsPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(FunctionsPackage.eNS_UR I,
> FunctionsPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(OrganisationsPackage.eN S_URI,
> OrganisationsPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(PrimitiveTypesPackage.e NS_URI,
> PrimitiveTypesPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ProcessesPackage.eNS_UR I,
> ProcessesPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ViewPackage.eNS_URI,
> ViewPackage.eINSTANCE);
> return resourceSet;
> }
> }
>
> org.hibernate.WrongClassException: Object with id: 16 was not of the specified subclass: OrganisationUnit (loaded object was of wrong class class de.uniAugsburg.agilPro.model.processes.impl.ActionImpl)
> at org.hibernate.loader.Loader.instanceAlreadyLoaded(Loader.jav a:1234)
> at org.hibernate.loader.Loader.getRow(Loader.java:1186)
> at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java: 568)
> at org.hibernate.loader.Loader.doQuery(Loader.java:689)
> at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyColle ctions(Loader.java:224)
> at org.hibernate.loader.Loader.loadCollection(Loader.java:1985)
> at org.hibernate.loader.collection.CollectionLoader.initialize( CollectionLoader.java:36)
> at org.hibernate.persister.collection.AbstractCollectionPersist er.initialize(AbstractCollectionPersister.java:565)
> at org.hibernate.event.def.DefaultInitializeCollectionEventList ener.onInitializeCollection(DefaultInitializeCollectionEvent Listener.java:60)
> at org.hibernate.impl.SessionImpl.initializeCollection(SessionI mpl.java:1716)
> at org.hibernate.collection.AbstractPersistentCollection.initia lize(AbstractPersistentCollection.java:344)
> at org.hibernate.collection.AbstractPersistentCollection.read(A bstractPersistentCollection.java:86)
> at org.hibernate.collection.PersistentList.toArray(PersistentLi st.java:123)
> at org.eclipse.emf.teneo.hibernate.mapping.elist.HibernatePersi stableEList.doLoad(HibernatePersistableEList.java:133)
> at org.eclipse.emf.teneo.mapping.elist.PersistableEList.load(Pe rsistableEList.java:199)
> at org.eclipse.emf.teneo.mapping.elist.PersistableEList.delegat eIsEmpty(PersistableEList.java:368)
> at org.eclipse.emf.common.util.DelegatingEList.isEmpty(Delegati ngEList.java:232)
> at de.uniAugsburg.agilPro.model.organisations.impl.RoleImpl.eIs Set(RoleImpl.java:155)
> at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eIsSet(BasicEObj ectImpl.java:818)
> at org.eclipse.emf.ecore.util.EContentsEList$FeatureIteratorImp l.hasNext(EContentsEList.java:414)
> at org.eclipse.emf.ecore.util.EObjectValidator.validate_EveryPr oxyResolves(EObjectValidator.java:328)
> at org.eclipse.emf.ecore.util.EObjectValidator.validate_EveryDe faultConstraint(EObjectValidator.java:183)
> at org.eclipse.emf.ecore.util.EObjectValidator.validate(EObject Validator.java:168)
> at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostic ian.java:127)
> at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostic ian.java:107)
> at org.eclipse.emf.teneo.resource.NonLoadingDiagnostician.doVal idateContents(NonLoadingDiagnostician.java:52)
> at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostic ian.java:130)
> at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostic ian.java:107)
> at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostic ian.java:87)
> at org.eclipse.emf.teneo.resource.StoreResource.validateObject( StoreResource.java:444)
> at org.eclipse.emf.teneo.resource.StoreResource.validateContent s(StoreResource.java:427)
> at org.eclipse.emf.teneo.resource.StoreResource.save(StoreResou rce.java:368)
> at de.uniAugsburg.agilPro.editors.AgilProEditor.doSave(AgilProE ditor.java:902)
> at org.eclipse.ui.internal.SaveableHelper$1.run(SaveableHelper. java:130)
> at org.eclipse.ui.internal.SaveableHelper$4.run(SaveableHelper. java:257)
> at org.eclipse.jface.operation.ModalContext.runInCurrentThread( ModalContext.java:369)
> at org.eclipse.jface.operation.ModalContext.run(ModalContext.ja va:313)
> at org.eclipse.jface.window.ApplicationWindow$1.run(Application Window.java:763)
> at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:67)
> at org.eclipse.jface.window.ApplicationWindow.run(ApplicationWi ndow.java:760)
> at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow. java:2283)
> at org.eclipse.ui.internal.SaveableHelper.runProgressMonitorOpe ration(SaveableHelper.java:263)
> at org.eclipse.ui.internal.SaveableHelper.runProgressMonitorOpe ration(SaveableHelper.java:243)
> at org.eclipse.ui.internal.SaveableHelper.savePart(SaveableHelp er.java:135)
> at org.eclipse.ui.internal.EditorManager.savePart(EditorManager .java:1414)
> at org.eclipse.ui.internal.WorkbenchPage.savePart(WorkbenchPage .java:2995)
> at org.eclipse.ui.internal.WorkbenchPage.saveEditor(WorkbenchPa ge.java:3008)
> at org.eclipse.ui.internal.SaveAction.run(SaveAction.java:67)
> at org.eclipse.jface.action.Action.runWithEvent(Action.java:499 )
> at org.eclipse.jface.commands.ActionHandler.execute(ActionHandl er.java:119)
> at org.eclipse.core.commands.Command.executeWithChecks(Command. java:461)
> at org.eclipse.core.commands.ParameterizedCommand.executeWithCh ecks(ParameterizedCommand.java:424)
> at org.eclipse.ui.internal.handlers.HandlerService.executeComma nd(HandlerService.java:160)
> at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeComman d(WorkbenchKeyboard.java:466)
> at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(Workben chKeyboard.java:799)
> at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEve nt(WorkbenchKeyboard.java:846)
> at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequ enceBindings(WorkbenchKeyboard.java:564)
> at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(Work benchKeyboard.java:506)
> at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter .handleEvent(WorkbenchKeyboard.java:122)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
> at org.eclipse.swt.widgets.Display.filterEvent(Display.java:982 )
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:927)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:952)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:937)
> at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:965)
> at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:961)
> at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1275)
> at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3346)
> at org.eclipse.swt.widgets.Control.windowProc(Control.java:3246 )
> at org.eclipse.swt.widgets.Display.windowProc(Display.java:4025 )
> at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
> at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:19 32)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2966)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1930)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1894)
> at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:422)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
> at de.uniAugsburg.agilPro.editors.rcp.Application.run(Applicati on.java:63)
> 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)


--

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+Hibernate] TransientObjectException while saving a resourc [message #604667 is a reply to message #79327] Thu, 12 April 2007 08:32 Go to previous message
Markus Bischof is currently offline Markus BischofFriend
Messages: 72
Registered: July 2009
Member
Hi Martin,

I found out, that the WrongClassException only occurs when I add a palette
the the editDomain:

protected void setEditDomain(EditDomain newEditDomain)
{
editDomain = newEditDomain;
if (editDomain instanceof GefEmfEditingDomain)
{
((GefEmfEditingDomain) editDomain)
.setEmfEditingDomain(createEmfEditingDomain());
}
editDomain.setPaletteRoot(getPaletteRoot()); // causes the error (****)
}

When I delete the setPaletteRoot-line, I can change and save the model
without the WrongClassException. I try to look deeper in the Palette-code
and see if there is something wrong...unfortunately I do not know for what I
am looking for...

Kind regards,
Markus
Re: [Teneo+Hibernate] TransientObjectException while saving a resourc [message #604688 is a reply to message #79541] Thu, 12 April 2007 11:38 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Ok, if you have a focused test case/project which replicates the issue then I can also look at it.
Have you tried to programmatically create the editing domain?

Here is a link to a post on this exception on the hibernate forum (but maybe you also found it):
http://forum.hibernate.org/viewtopic.php?t=938520&sid=2e 7dda00efe2c8b8da6fa0799800af52

gr. Martin

Markus Bischof wrote:
> Hi Martin,
>
> I found out, that the WrongClassException only occurs when I add a palette
> the the editDomain:
>
> protected void setEditDomain(EditDomain newEditDomain)
> {
> editDomain = newEditDomain;
> if (editDomain instanceof GefEmfEditingDomain)
> {
> ((GefEmfEditingDomain) editDomain)
> .setEmfEditingDomain(createEmfEditingDomain());
> }
> editDomain.setPaletteRoot(getPaletteRoot()); // causes the error (****)
> }
>
> When I delete the setPaletteRoot-line, I can change and save the model
> without the WrongClassException. I try to look deeper in the Palette-code
> and see if there is something wrong...unfortunately I do not know for what I
> am looking for...
>
> Kind regards,
> Markus
>
>


--

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
e: [Teneo+Hibernate] TransientObjectException while saving a resourc [message #604695 is a reply to message #79619] Thu, 12 April 2007 13:49 Go to previous message
Markus Bischof is currently offline Markus BischofFriend
Messages: 72
Registered: July 2009
Member
Hi Martin!

I've finally managed to create a test-project, where you can see the
WrongClassException! Unfortunately I had to add some javafiles and some code
from the real application, which I did not write by myself to comile the
project. I hope the code is not too confusing (e.g. I had to add the
Palette.java-file where somehow the error comes from)!

I've added some comments in the AgilProTests.java-File, too, but I will
shortly explain, what causes the error:

First you have to save the model from the filesystem in the database. For
this, you just have to run the AgilProTests-file. It should save the model
in the database (using the loadAndSaveModel()-method).

After that you have to delete (or comment) the
instance.loadAndSaveModel()-method, and use the
instance.loadAndChangeModel()-method instead (in the main-method). Now an
exception is thrown...

I also added a deleteModel()-method, which tries to delete the model. This
method also fails, when it is called alone in a run (without the method
instance.loadAndSaveModel()).

I hope you can reconstruct the exception.

As I mentioned, I found out, that somehow the palette causes the error. I
you delete the line:

editDomain.setPaletteRoot(...)

in the createEditDomain()-method, everything works fine (also the deleting
of the model!!!) Because of this, I assume that somehow the palette causes
the error...

As you will see, there is only an exception when the changing or deleting of
the Resource-contents are done within a separate run. If you call the
methods within one single run, everything works fine...

Finally, I hope you can download the file and test the project...I've had to
remove the imported libraries, because the file would be too big...how can I
send them to you?

With kind regards,
Markus Bischof



  • Attachment: agil-mod.zip
    (Size: 421.84KB, Downloaded 107 times)
Re: e: [Teneo+Hibernate] TransientObjectException while saving a resourc [message #604697 is a reply to message #79665] Thu, 12 April 2007 14:00 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Markus,
No problem I have the hibernate libraries (if you mean that) with source code and all so that makes
debugging easier. I won't have time tomorrow probably but over the weekend I will look at it.

gr. Martin

Markus Bischof wrote:
> Hi Martin!
>
> I've finally managed to create a test-project, where you can see the
> WrongClassException! Unfortunately I had to add some javafiles and some code
> from the real application, which I did not write by myself to comile the
> project. I hope the code is not too confusing (e.g. I had to add the
> Palette.java-file where somehow the error comes from)!
>
> I've added some comments in the AgilProTests.java-File, too, but I will
> shortly explain, what causes the error:
>
> First you have to save the model from the filesystem in the database. For
> this, you just have to run the AgilProTests-file. It should save the model
> in the database (using the loadAndSaveModel()-method).
>
> After that you have to delete (or comment) the
> instance.loadAndSaveModel()-method, and use the
> instance.loadAndChangeModel()-method instead (in the main-method). Now an
> exception is thrown...
>
> I also added a deleteModel()-method, which tries to delete the model. This
> method also fails, when it is called alone in a run (without the method
> instance.loadAndSaveModel()).
>
> I hope you can reconstruct the exception.
>
> As I mentioned, I found out, that somehow the palette causes the error. I
> you delete the line:
>
> editDomain.setPaletteRoot(...)
>
> in the createEditDomain()-method, everything works fine (also the deleting
> of the model!!!) Because of this, I assume that somehow the palette causes
> the error...
>
> As you will see, there is only an exception when the changing or deleting of
> the Resource-contents are done within a separate run. If you call the
> methods within one single run, everything works fine...
>
> Finally, I hope you can download the file and test the project...I've had to
> remove the imported libraries, because the file would be too big...how can I
> send them to you?
>
> With kind regards,
> Markus Bischof
>
>
>


--

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+Hibernate] TransientObjectException while saving a resourc [message #604906 is a reply to message #78872] Mon, 23 April 2007 04:10 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Markus,
I have finally had time to look at this issue. Sorry that this look longer than I promised.

This issue (at least the one in the testcase) is caused by the following association:
- the performedby efeature from role to organisationunit: this association is stored in the column:
role_performedby_e_id
- the performedby efeature from action to role: this association is stored in the column:
role_performedby_e_id

because both organisationunit and action are stored in the same table (the modelelement) this means
that when the testset is created that the action object refers to a role, then when the action is
saved the reference to role is saved in the role_performedby_e_id column. Then when the data is
loaded and the role is loaded then the system reads the organisationunits and accidently reads an
action object (because it uses the same role_performedby_e_id column) which it does not expect.

This issue occurs because accidently the name of the efeature in the role and the action have the
same name and colliding reference and the organisationunit is stored in the same table as the action.

You can solve this issue by either using a joined table inheritance mapping strategy or by adding a
JoinColumn annotation to either of the two above associations so that the two associations are not
mapped to the same column.
for example:
@JoinColumn(name="actionToRole referencedColumnName="e_id")

For a later release I'll think about a strategy to always generate unique joincolumn and jointable
names with the disadvantage of longer table/columnnames.

gr. Martin

Markus Bischof wrote:
> Hi Martin!
>
>> A few questions.
>> Can you post some sample code? I mean: what does connect the 2 items with
>> a ReferenceImpl mean? What
>> is the exact error message/stack trace you get? How do you reload in the
>> editor?
> See stacktrace.txt for the complete stacktrace. "Connecting" 2 items means,
> that I have 2 elements in the GUI and I draw a line from one item to another
> (in my case this is done using a ReferenceImpl-object). I don't know exactly
> how the reloading is done in the editor (do you mean reloading of the
> changed resource?) because I did not code that and therefore I do not know
> where to look for that....I've added manualcode.txt for some samplecode
> which load the test.agilpro file, saves it in the database and then loads it
> again and changes the position of the action (which works fine). I that case
> I manually craete the Resource, and I think that because of this it works...
>
>
>> In the database: the modelelement table contains an id and a dtype column,
>> can you use the id
>> (listed in the error message) to check in the modelelement table what the
>> content of the dtype
>> column is?
> The dtype is Action.
>
>
>> Did you follow the exact same scenario in the manual case as in the editor
>> case (the descriptions
>> differ)? In the manual scenario did you re-use the same resource for all
>> actions?
> The difference between manual and the editor case is, that in the manual
> case, I do not have a EMF-EditingDomain, so that I craete a Resourceset
> myself and let it create a HibernateResource (see manualcode.txt for that).
> In the editorcase I just create the URI and the I call
>
> mainModelResource =
> getEmfEditingDomain().getResourceSet().getResource(resourceU ri, true);
>
> which creates the HibernateResource automatically. I think that there is
> something wrong...
>
> In the manual case I cannot do this, because there is no EmfEditingDomain
> (at least I don't know how to get it...)
>
> In the manual case I can load the resource and change e.g. the position. In
> the editorcase I can move an item in the GUI to another location, but when I
> want to save the resource, I get that error. As mentioned, I think there is
> somthing wrong with the EmfEditingDomain-resource-loading...could it be that
> some epackages are missing there?!
>
> I've added the model which causes the WronClassException when it is saved in
> the database and loaded through the EmfEditingDomain.
>
> I hope this is useful!!!!
>
> Kind regards...
> Markus
>
>
>
> package agilprotests;
>
> import java.io.IOException;
> import java.util.Collections;
> import java.util.Properties;
>
> import model.application.ApplicationPackage;
> import model.core.CorePackage;
> import model.core.impl.PackageImpl;
> import model.data.DataPackage;
> import model.events.EventsPackage;
> import model.functions.FunctionsPackage;
> import model.organisations.OrganisationsPackage;
> import model.primitiveTypes.PrimitiveTypesPackage;
> import model.processes.ProcessesPackage;
> import model.processes.impl.ActionImpl;
> import model.processes.impl.ActivityImpl;
> import model.processes.impl.ReferenceImpl;
> import model.view.Point;
> import model.view.ViewPackage;
> import model.view.impl.PointImpl;
>
> import org.eclipse.emf.common.util.URI;
> import org.eclipse.emf.ecore.EPackage;
> import org.eclipse.emf.ecore.resource.Resource;
> import org.eclipse.emf.ecore.resource.ResourceSet;
> import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
> import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
> import org.eclipse.emf.teneo.hibernate.HbDataStore;
> import org.eclipse.emf.teneo.hibernate.HbHelper;
> import org.eclipse.emf.teneo.hibernate.resource.HibernateResourceFa ctory;
> import org.hibernate.cfg.Environment;
>
> import junit.framework.TestCase;
>
> public class AgilProTests extends TestCase {
>
> private HbDataStore hbds=null;
>
> @Override
> protected void setUp() throws Exception {
> if(hbds==null)
> initHibernateStore();
> }
>
> private void initHibernateStore() {
> System.out.println("setup!");
> // Initialize the HbDataStore
> hbds = HbHelper.INSTANCE.createRegisterDataStore("agilprodb");
> hbds.setEPackages(new EPackage[]{CorePackage.eINSTANCE,
> ApplicationPackage.eINSTANCE,
> DataPackage.eINSTANCE,
> EventsPackage.eINSTANCE,
> FunctionsPackage.eINSTANCE,
> OrganisationsPackage.eINSTANCE,
> PrimitiveTypesPackage.eINSTANCE,
> ProcessesPackage.eINSTANCE,
> ViewPackage.eINSTANCE});
> hbds.setHibernateProperties(getDatabaseProperties());
> hbds.initialize();
> }
>
> private Properties getDatabaseProperties() {
>
> // generate properties
> Properties props = new Properties();
> props.setProperty(Environment.DRIVER, "com.mysql.jdbc.Driver");
> props.setProperty(Environment.USER, "root");
> props.setProperty(Environment.URL, "jdbc:mysql://127.0.0.1:3306/teneotestbase");
> props.setProperty(Environment.PASS, "root");
> props.setProperty(Environment.DIALECT, org.hibernate.dialect.MySQLInnoDBDialect.class.getName());
> props.setProperty(Environment.CURRENT_SESSION_CONTEXT_CLASS, "thread");
>
> // return result
> return props;
> }
>
> public void testClear() {
> try {
> // load standardpalette from filesystem
> ResourceSet resourceSet2 = createXMIResourceSet();
> URI fileURI = URI.createURI("test.agilpro");
> Resource fileResource = resourceSet2.createResource(fileURI);
> fileResource.load(Collections.EMPTY_MAP);
>
> // save somemodel in database
> ResourceSet resourceSet = createHibernateResourceSet();
> URI databaseURI = URI.createURI("hibernate://?dsname=agilprodb&query1=from Package where name='test'");
> Resource databaseResource = resourceSet.createResource(databaseURI);
> databaseResource.load(Collections.EMPTY_MAP);
> databaseResource.getContents().add(fileResource.getAllConten ts().next());
>
> // set rootname and save resource
> ((PackageImpl)databaseResource.getContents().get(0)).setName ( "test");
> databaseResource.save(Collections.EMPTY_MAP);
>
> // load again
> databaseResource.load(Collections.EMPTY_MAP);
>
> // pick an item
> PackageImpl root = (PackageImpl)databaseResource.getContents().get(0);
> ActivityImpl act = (ActivityImpl)root.getElements().get(0);
> ActionImpl action = (ActionImpl)act.getNodes().get(0);
> PointImpl point = (PointImpl)action.getLocation();
> point.setX(50);
> point.setY(100);
> action.setLocation(point);
> databaseResource.save(Collections.EMPTY_MAP);
> }
> catch(Exception ex) {
> ex.printStackTrace();
> assertTrue(false);
> }
> }
>
> private ResourceSet createXMIResourceSet() {
> // create resourceset
> ResourceSet resourceSet = new ResourceSetImpl();
>
> // register extension for XMI and database resources
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap()
> .put("agilpro", new XMIResourceFactoryImpl());
>
> // register epackages
> resourceSet.getPackageRegistry().put(CorePackage.eNS_URI,
> CorePackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ProcessesPackage.eNS_UR I,
> ProcessesPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ApplicationPackage.eNS_ URI,
> ApplicationPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(DataPackage.eNS_URI,
> DataPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(EventsPackage.eNS_URI,
> EventsPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(FunctionsPackage.eNS_UR I,
> FunctionsPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(OrganisationsPackage.eN S_URI,
> OrganisationsPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(PrimitiveTypesPackage.e NS_URI,
> PrimitiveTypesPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ProcessesPackage.eNS_UR I,
> ProcessesPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ViewPackage.eNS_URI,
> ViewPackage.eINSTANCE);
> return resourceSet;
> }
>
> private ResourceSet createHibernateResourceSet() {
> // create resourceset
> ResourceSet resourceSet = new ResourceSetImpl();
>
> // register extension for XMI and database resources
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap()
> .put("agilprodb", new HibernateResourceFactory());
>
> // register epackages
> resourceSet.getPackageRegistry().put(CorePackage.eNS_URI,
> CorePackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ProcessesPackage.eNS_UR I,
> ProcessesPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ApplicationPackage.eNS_ URI,
> ApplicationPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(DataPackage.eNS_URI,
> DataPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(EventsPackage.eNS_URI,
> EventsPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(FunctionsPackage.eNS_UR I,
> FunctionsPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(OrganisationsPackage.eN S_URI,
> OrganisationsPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(PrimitiveTypesPackage.e NS_URI,
> PrimitiveTypesPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ProcessesPackage.eNS_UR I,
> ProcessesPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ViewPackage.eNS_URI,
> ViewPackage.eINSTANCE);
> return resourceSet;
> }
> }
>
> org.hibernate.WrongClassException: Object with id: 16 was not of the specified subclass: OrganisationUnit (loaded object was of wrong class class de.uniAugsburg.agilPro.model.processes.impl.ActionImpl)
> at org.hibernate.loader.Loader.instanceAlreadyLoaded(Loader.jav a:1234)
> at org.hibernate.loader.Loader.getRow(Loader.java:1186)
> at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java: 568)
> at org.hibernate.loader.Loader.doQuery(Loader.java:689)
> at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyColle ctions(Loader.java:224)
> at org.hibernate.loader.Loader.loadCollection(Loader.java:1985)
> at org.hibernate.loader.collection.CollectionLoader.initialize( CollectionLoader.java:36)
> at org.hibernate.persister.collection.AbstractCollectionPersist er.initialize(AbstractCollectionPersister.java:565)
> at org.hibernate.event.def.DefaultInitializeCollectionEventList ener.onInitializeCollection(DefaultInitializeCollectionEvent Listener.java:60)
> at org.hibernate.impl.SessionImpl.initializeCollection(SessionI mpl.java:1716)
> at org.hibernate.collection.AbstractPersistentCollection.initia lize(AbstractPersistentCollection.java:344)
> at org.hibernate.collection.AbstractPersistentCollection.read(A bstractPersistentCollection.java:86)
> at org.hibernate.collection.PersistentList.toArray(PersistentLi st.java:123)
> at org.eclipse.emf.teneo.hibernate.mapping.elist.HibernatePersi stableEList.doLoad(HibernatePersistableEList.java:133)
> at org.eclipse.emf.teneo.mapping.elist.PersistableEList.load(Pe rsistableEList.java:199)
> at org.eclipse.emf.teneo.mapping.elist.PersistableEList.delegat eIsEmpty(PersistableEList.java:368)
> at org.eclipse.emf.common.util.DelegatingEList.isEmpty(Delegati ngEList.java:232)
> at de.uniAugsburg.agilPro.model.organisations.impl.RoleImpl.eIs Set(RoleImpl.java:155)
> at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eIsSet(BasicEObj ectImpl.java:818)
> at org.eclipse.emf.ecore.util.EContentsEList$FeatureIteratorImp l.hasNext(EContentsEList.java:414)
> at org.eclipse.emf.ecore.util.EObjectValidator.validate_EveryPr oxyResolves(EObjectValidator.java:328)
> at org.eclipse.emf.ecore.util.EObjectValidator.validate_EveryDe faultConstraint(EObjectValidator.java:183)
> at org.eclipse.emf.ecore.util.EObjectValidator.validate(EObject Validator.java:168)
> at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostic ian.java:127)
> at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostic ian.java:107)
> at org.eclipse.emf.teneo.resource.NonLoadingDiagnostician.doVal idateContents(NonLoadingDiagnostician.java:52)
> at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostic ian.java:130)
> at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostic ian.java:107)
> at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostic ian.java:87)
> at org.eclipse.emf.teneo.resource.StoreResource.validateObject( StoreResource.java:444)
> at org.eclipse.emf.teneo.resource.StoreResource.validateContent s(StoreResource.java:427)
> at org.eclipse.emf.teneo.resource.StoreResource.save(StoreResou rce.java:368)
> at de.uniAugsburg.agilPro.editors.AgilProEditor.doSave(AgilProE ditor.java:902)
> at org.eclipse.ui.internal.SaveableHelper$1.run(SaveableHelper. java:130)
> at org.eclipse.ui.internal.SaveableHelper$4.run(SaveableHelper. java:257)
> at org.eclipse.jface.operation.ModalContext.runInCurrentThread( ModalContext.java:369)
> at org.eclipse.jface.operation.ModalContext.run(ModalContext.ja va:313)
> at org.eclipse.jface.window.ApplicationWindow$1.run(Application Window.java:763)
> at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:67)
> at org.eclipse.jface.window.ApplicationWindow.run(ApplicationWi ndow.java:760)
> at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow. java:2283)
> at org.eclipse.ui.internal.SaveableHelper.runProgressMonitorOpe ration(SaveableHelper.java:263)
> at org.eclipse.ui.internal.SaveableHelper.runProgressMonitorOpe ration(SaveableHelper.java:243)
> at org.eclipse.ui.internal.SaveableHelper.savePart(SaveableHelp er.java:135)
> at org.eclipse.ui.internal.EditorManager.savePart(EditorManager .java:1414)
> at org.eclipse.ui.internal.WorkbenchPage.savePart(WorkbenchPage .java:2995)
> at org.eclipse.ui.internal.WorkbenchPage.saveEditor(WorkbenchPa ge.java:3008)
> at org.eclipse.ui.internal.SaveAction.run(SaveAction.java:67)
> at org.eclipse.jface.action.Action.runWithEvent(Action.java:499 )
> at org.eclipse.jface.commands.ActionHandler.execute(ActionHandl er.java:119)
> at org.eclipse.core.commands.Command.executeWithChecks(Command. java:461)
> at org.eclipse.core.commands.ParameterizedCommand.executeWithCh ecks(ParameterizedCommand.java:424)
> at org.eclipse.ui.internal.handlers.HandlerService.executeComma nd(HandlerService.java:160)
> at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeComman d(WorkbenchKeyboard.java:466)
> at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(Workben chKeyboard.java:799)
> at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEve nt(WorkbenchKeyboard.java:846)
> at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequ enceBindings(WorkbenchKeyboard.java:564)
> at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(Work benchKeyboard.java:506)
> at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter .handleEvent(WorkbenchKeyboard.java:122)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
> at org.eclipse.swt.widgets.Display.filterEvent(Display.java:982 )
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:927)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:952)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:937)
> at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:965)
> at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:961)
> at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1275)
> at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3346)
> at org.eclipse.swt.widgets.Control.windowProc(Control.java:3246 )
> at org.eclipse.swt.widgets.Display.windowProc(Display.java:4025 )
> at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
> at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:19 32)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2966)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1930)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1894)
> at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:422)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
> at de.uniAugsburg.agilPro.editors.rcp.Application.run(Applicati on.java:63)
> 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)


--

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+Hibernate] TransientObjectException while saving a resourc [message #604932 is a reply to message #80605] Mon, 23 April 2007 18:17 Go to previous message
Markus Bischof is currently offline Markus BischofFriend
Messages: 72
Registered: July 2009
Member
Hi Martin!

Thanks for looking at my issue...

I tried to create a joined-subclass inheritance using the "Teneo->Generate
EMF - Hibernate OR Mapping (joind-subclass)"-menu command. I placed the
generated hibernate.hbm.xml-file in my "src" folder.
Unfortunately the method hbdatastore.getMappingXML() returns the "old"
(superclass-) mapping. Where does the hbdatastore get that mapping-xml from
(there is no file which contains that), and how can I try the new
joined-subclass xml-mapping?

gr.
Markus
Re: [Teneo+Hibernate] TransientObjectException while saving a resourc [message #604933 is a reply to message #80725] Mon, 23 April 2007 19:15 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Markus,
Teneo creates a mapping when the datastore is initialized (unless you tell the datastore to use a
hbm file in the classpath (see the options)). In practice I would use this auto-generation instead
of generating a mapping through the menu option. The mapping generation through the datastore can be
influenced by annotations and many different options (passed through the setPersistenceProperties
method):
http://www.elver.org/hibernate/options.html

one of the options influences the inheritance mapping strategy.

gr. Martin


Markus Bischof wrote:
> Hi Martin!
>
> Thanks for looking at my issue...
>
> I tried to create a joined-subclass inheritance using the "Teneo->Generate
> EMF - Hibernate OR Mapping (joind-subclass)"-menu command. I placed the
> generated hibernate.hbm.xml-file in my "src" folder.
> Unfortunately the method hbdatastore.getMappingXML() returns the "old"
> (superclass-) mapping. Where does the hbdatastore get that mapping-xml from
> (there is no file which contains that), and how can I try the new
> joined-subclass xml-mapping?
>
> gr.
> Markus
>
>


--

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+Hibernate] TransientObjectException while saving a resourc [message #604954 is a reply to message #80746] Tue, 24 April 2007 07:54 Go to previous message
Markus Bischof is currently offline Markus BischofFriend
Messages: 72
Registered: July 2009
Member
Hi Martin!

Ok, I changed the inheritancemapping-strategy and now the testmodel can be
saved.

But with that strategy, some bigger model throws an

java.sql.BatchUpdateException: Cannot add or update a child row: a foreign
key constraint fails (`teneotestbase/activityedge`, CONSTRAINT
`FK611D414C5DEE9828` FOREIGN KEY (`activityedge_source_e_id`) REFERENCES
`structuredactivitynode` (`scope_e_id`))

I attached the project and the model for which that exception occurs...if
you find some time, you may want to look at it.

Markus


  • Attachment: agil-mod.zip
    (Size: 423.88KB, Downloaded 124 times)
Re: [Teneo+Hibernate] TransientObjectException while saving a resourc [message #604958 is a reply to message #80811] Tue, 24 April 2007 08:10 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Markus,
Yes, I am fairly busy so it would be maybe quicker if you do some searching yourselve. Either the
reference (from activityedge.source to structuredactivitynode) is not set while it is mandatory or
it is set but the structuredactivitynode does not exist yet in the db.

If you use mysql you can do show innodb status in the mysql command line to get the a message on
what failed. Also placing a break point in where hibernate throws the catches/rethrows the exception
should allow you to get more information.

gr. Martin

Markus Bischof wrote:
> Hi Martin!
>
> Ok, I changed the inheritancemapping-strategy and now the testmodel can be
> saved.
>
> But with that strategy, some bigger model throws an
>
> java.sql.BatchUpdateException: Cannot add or update a child row: a foreign
> key constraint fails (`teneotestbase/activityedge`, CONSTRAINT
> `FK611D414C5DEE9828` FOREIGN KEY (`activityedge_source_e_id`) REFERENCES
> `structuredactivitynode` (`scope_e_id`))
>
> I attached the project and the model for which that exception occurs...if
> you find some time, you may want to look at it.
>
> Markus
>
>


--

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:[teneo] EMF 2.2.1 vs EMF 2.3.x for Teneo 0.8x
Next Topic:[Teneo] : Transient annotation not working on EClass.
Goto Forum:
  


Current Time: Thu Mar 28 23:42:29 GMT 2024

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

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

Back to the top