Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » [Teneo] Unload() questions
|
Re: [Teneo] Unload() questions [message #117994 is a reply to message #117967] |
Sat, 12 April 2008 20:43 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Manfred,
Fmi, which version of Teneo are you using?
The unload clears the resource but it should not result in any database actions. During the clear of
the resource contents the detached method is called which calls detachedHelper which calls
removedEObject. However these methods don't do much more than putting the objects in the
deletedObjects array and removing them from the newobjects/loadedobjects arrays. As long as save is
not called this should not result in actually removing the objects from the db. What you can do is
enabled hibernate logging and see if hibernate logs any actions during the unload.
Can you let me know what you find here?
To fight the symptom what you can do is set the hibernate flushmode to commit. So then hibernate
will only flush changes to the db when you call an explicit commit on the transaction. But this will
only solve the symptom and not the underlying cause...
I can imagine that you need to save the hibernate resource before the separate gmf xml resource
because otherwise the references from the gmf resource to the (hibernate) objects can't use the
primary keys.
Note a difference between your approach and the approach in the teneo-gmf tutorial is that in the
tutorial I use one resource for both the diagram and the model data.
gr. Martin
Manfred Hahn wrote:
> Hi Martin,
>
> I have a question concerning the unload() function. When I started to
> work with Teneo, I put the GMF model into the hibernate database as you
> did in your GMF tutorial. I had some "java.lang.IllegalStateException:
> Cannot modify resource set without a write transaction" notes in the
> .log file during unload, so I put an EMF transaction and a Hibernate
> transaction around the unload() statement in
> XxxDocumentProvider$ResourceSetInfo.dispose(). The exceptions in .log
> where gone.
>
> Now I decided to go a step back and use the XML representation of the
> GMF model, leaving the logical model in the hibernate database. (In fact
> I put the XML representation in a blob field of the database. I wrote a
> special URL handling in the way I had seen in Teneo to manage that.)
> But then I discoverd that the model storage seemed to behave in an
> unpredictable way: sometimes objects vanished from the model after
> storing and reloading. I found out that hibernate deleted objects during
> the unload of the resource because they had been marked as orphaned.
> Every child object that had been loaded from the database was deleted;
> newly created child objects were stored in the database. The reason for
> this I don't know exactly but I think the clearing of the resource
> contents has something to do with it and the splitting of the resource
> types. Just to be shure that my URL handling is not buggy I changed it
> to a real file URL for the GMF model. The problems were the same.
>
> So I changed the XxxDocumentProvider$ResourceSetInfo.dispose() back to
> its original. Now the database problems are gone but the "Cannot modify
> resource set.." exception is again in the .log file.
>
> I manage the hibernate session with one session controller. I have no
> open transactions when the application is closed. All database storage
> actions are done in the doSave() method. So I expect the unload()
> function to do nothing on the database.
>
> These are my questions: What database actions are expected to be done
> during unload()? Should there be an EMF and hibernate transaction open?
> Do I have to do something special during unload with my two resource
> type, e.g. unloading them in a special sequence? (I had to do this in
> doSave() to ensure that the primary keys are set when I store the XML
> GMF resource)
>
> Best regards
> Manfred
>
>
--
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] Unload() questions [message #118295 is a reply to message #117994] |
Mon, 14 April 2008 11:29 |
Manfred Hahn Messages: 64 Registered: July 2009 |
Member |
|
|
Hi Martin,
my Teneo version is 0.8.0.v200804061007
In the meantime I have a solution, but no understanding..;-)
This is the scenario:
Loading of a model with one root object and one child. (And another root
object in another resource, to be honest)
Storing the model with "save" (without any previous or later changes).
Closing the program.
When I have the original dispose() method, the unload does a .log entry:
!MESSAGE Cannot modify resource set without a write transaction
!STACK 0
java.lang.IllegalStateException: Cannot modify resource set without a
write transaction
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:322)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:284)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:266)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:222)
at
org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:247)
at
org.eclipse.emf.common.notify.impl.NotificationImpl.dispatch (NotificationImpl.java:1030)
at
org.eclipse.emf.common.notify.impl.NotifyingListImpl.clear(N otifyingListImpl.java:1101)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.doUnload(Re sourceImpl.java:1472)
at
org.eclipse.emf.teneo.resource.StoreResource.doUnload(StoreR esource.java:370)
at
org.eclipse.emf.teneo.hibernate.resource.HibernateResource.d oUnload(HibernateResource.java:410)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.unload(Reso urceImpl.java:1494)
at
de.edvchl.clic.workflow.diagram.part.WorkflowDocumentProvide r$ResourceSetInfo.dispose(WorkflowDocumentProvider.java:732)
So I changed the dispose() function like this:
public void dispose() {
getResourceSet().eAdapters().remove(myResourceSetListener);
TransactionalEditingDomain editingDomain = getEditingDomain();
final EditingDomainHandler handler =
EditingDomainHandler.getEditingDomainHandler();
Command cmd = new RecordingCommand(editingDomain){
@Override
protected void doExecute() {
handler.getSessionController().getSessionWrapper().beginTran saction();
try {
for (Resource resource : getResourceSet().getResources()) {
resource.unload();
}
handler.getSessionController().getSessionWrapper().commitTra nsaction();
}
catch (RuntimeException e) {
handler.getSessionController().getSessionWrapper().rollbackT ransaction();
throw e;
}
}
};
editingDomain.getCommandStack().execute(cmd);
}
(The handler is just a simple helper class to get always the one and only
SessionController)
The unload() has no more Exceptions, but the log4j-log shows:
136736 [main] DEBUG
org.eclipse.emf.teneo.hibernate.resource.HibernateResource - Doing
unload, has session controller, sessioncontroller is therefor responsible
for session close
136746 [main] DEBUG
org.eclipse.emf.teneo.hibernate.resource.HibernateResource - Doing
unload, has session controller, sessioncontroller is therefor responsible
for session close
136746 [main] DEBUG org.hibernate.transaction.JDBCTransaction - commit
136746 [main] DEBUG org.hibernate.impl.SessionImpl - automatically
flushing session
136746 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener
- flushing session
136746 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener
- processing flush-time cascades
136746 [main] DEBUG org.hibernate.engine.Cascade - processing cascade
ACTION_SAVE_UPDATE for: Prozess
136746 [main] DEBUG org.hibernate.engine.Cascade - cascade
ACTION_SAVE_UPDATE for collection: Prozess.elemente
136746 [main] DEBUG org.hibernate.engine.Cascade - done cascade
ACTION_SAVE_UPDATE for collection: Prozess.elemente
136746 [main] DEBUG org.hibernate.engine.Cascade - deleting orphans for
collection: Prozess.elemente
136746 [main] DEBUG org.hibernate.engine.Cascade - deleting orphaned
entity instance: ProzessElement
136756 [main] DEBUG org.hibernate.event.def.DefaultDeleteEventListener -
deleting a persistent instance
136756 [main] DEBUG org.hibernate.event.def.DefaultDeleteEventListener -
deleting [Aktivitaet#402884e9194c8ec501194c90f7fe0004]
So my only child object has been deleted!
My solution is, to do an EMF transaction without a hibernate transaction.
Then everything is ok, no more exception and no deletes.
What is wrong with the hibernate transaction?
The previous save shows a clean flush without any changes in the database.
gr. Manfred
|
|
|
Re: [Teneo] Unload() questions [message #118333 is a reply to message #118295] |
Mon, 14 April 2008 17:58 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Manfred,
It seems that the unload removes the child from the parent collection. To be sure can you try/check
the following:
- is the child present in the collection before the unload?
- is the child present in the collection after the unload but before the commit?
gr. Martin
Manfred Hahn wrote:
> Hi Martin,
>
> my Teneo version is 0.8.0.v200804061007
>
> In the meantime I have a solution, but no understanding..;-)
>
> This is the scenario:
> Loading of a model with one root object and one child. (And another root
> object in another resource, to be honest)
> Storing the model with "save" (without any previous or later changes).
> Closing the program.
>
> When I have the original dispose() method, the unload does a .log entry:
>
> !MESSAGE Cannot modify resource set without a write transaction
> !STACK 0
> java.lang.IllegalStateException: Cannot modify resource set without a
> write transaction
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:322)
>
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:284)
>
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:266)
>
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:222)
>
> at
> org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:247)
>
> at
> org.eclipse.emf.common.notify.impl.NotificationImpl.dispatch (NotificationImpl.java:1030)
>
> at
> org.eclipse.emf.common.notify.impl.NotifyingListImpl.clear(N otifyingListImpl.java:1101)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.doUnload(Re sourceImpl.java:1472)
>
> at
> org.eclipse.emf.teneo.resource.StoreResource.doUnload(StoreR esource.java:370)
>
> at
> org.eclipse.emf.teneo.hibernate.resource.HibernateResource.d oUnload(HibernateResource.java:410)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.unload(Reso urceImpl.java:1494)
>
> at
> de.edvchl.clic.workflow.diagram.part.WorkflowDocumentProvide r$ResourceSetInfo.dispose(WorkflowDocumentProvider.java:732)
>
>
>
> So I changed the dispose() function like this:
>
> public void dispose() {
> getResourceSet().eAdapters().remove(myResourceSetListener);
> TransactionalEditingDomain editingDomain = getEditingDomain();
> final EditingDomainHandler handler =
> EditingDomainHandler.getEditingDomainHandler();
> Command cmd = new RecordingCommand(editingDomain){
>
> @Override
> protected void doExecute() {
>
> handler.getSessionController().getSessionWrapper().beginTran saction();
> try {
> for (Resource resource :
> getResourceSet().getResources()) {
> resource.unload();
> }
>
> handler.getSessionController().getSessionWrapper().commitTra nsaction();
> }
> catch (RuntimeException e) {
>
> handler.getSessionController().getSessionWrapper().rollbackT ransaction();
> throw e;
> }
> }
>
> };
> editingDomain.getCommandStack().execute(cmd);
> }
>
>
> (The handler is just a simple helper class to get always the one and
> only SessionController)
>
> The unload() has no more Exceptions, but the log4j-log shows:
> 136736 [main] DEBUG
> org.eclipse.emf.teneo.hibernate.resource.HibernateResource - Doing
> unload, has session controller, sessioncontroller is therefor
> responsible for session close
> 136746 [main] DEBUG
> org.eclipse.emf.teneo.hibernate.resource.HibernateResource - Doing
> unload, has session controller, sessioncontroller is therefor
> responsible for session close
> 136746 [main] DEBUG org.hibernate.transaction.JDBCTransaction - commit
> 136746 [main] DEBUG org.hibernate.impl.SessionImpl - automatically
> flushing session
> 136746 [main] DEBUG
> org.hibernate.event.def.AbstractFlushingEventListener - flushing session
> 136746 [main] DEBUG
> org.hibernate.event.def.AbstractFlushingEventListener - processing
> flush-time cascades
> 136746 [main] DEBUG org.hibernate.engine.Cascade - processing cascade
> ACTION_SAVE_UPDATE for: Prozess
> 136746 [main] DEBUG org.hibernate.engine.Cascade - cascade
> ACTION_SAVE_UPDATE for collection: Prozess.elemente
> 136746 [main] DEBUG org.hibernate.engine.Cascade - done cascade
> ACTION_SAVE_UPDATE for collection: Prozess.elemente
> 136746 [main] DEBUG org.hibernate.engine.Cascade - deleting orphans for
> collection: Prozess.elemente
> 136746 [main] DEBUG org.hibernate.engine.Cascade - deleting orphaned
> entity instance: ProzessElement
> 136756 [main] DEBUG org.hibernate.event.def.DefaultDeleteEventListener
> - deleting a persistent instance
> 136756 [main] DEBUG org.hibernate.event.def.DefaultDeleteEventListener
> - deleting [Aktivitaet#402884e9194c8ec501194c90f7fe0004]
>
>
> So my only child object has been deleted!
>
> My solution is, to do an EMF transaction without a hibernate transaction.
> Then everything is ok, no more exception and no deletes.
>
> What is wrong with the hibernate transaction?
> The previous save shows a clean flush without any changes in the database.
>
> gr. Manfred
>
--
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] Unload() questions [message #118391 is a reply to message #118377] |
Tue, 15 April 2008 13:01 |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
Martin,
I know solve folks specialize the unload behavior to decompose the
containment structure of the unloaded tree of objects. That's not the
default behavior though...
Martin Taal wrote:
> Hi Manfred,
> I tested the unload and in my case the children remain in the parent
> (I tested using the Library/Book/Writer example). In your case I don't
> know which eventlistener causes the remove of the child. So the only
> option is to debug through the unload action and see what happens.
>
> gr. Martin
>
> Manfred Hahn wrote:
>> Hi Martin,
>>
>> yes, you are right! Before the unload everything is ok, but after the
>> unload the resource is empty (I expected this) and the model root
>> element has lost its child (I didn't expect this).
>> Is there a chain of events / event listeners that do this change
>> during the clearing of the resource contents list?
>>
>> gr. Manfred
>>
>
>
|
|
|
Re: [Teneo] Unload() questions [message #118415 is a reply to message #118377] |
Tue, 15 April 2008 15:01 |
Manfred Hahn Messages: 64 Registered: July 2009 |
Member |
|
|
Hi Martin,
I've debugged the unload() and came to the following stack:
ProzessImpl.eInverseRemove(InternalEObject, int, NotificationChain) line:
245
ProzessImpl(BasicEObjectImpl).eInverseRemove(InternalEObject , int,
Class<?>, NotificationChain) line: 1421
AktivitaetImpl(ProzessElementImpl).eBasicRemoveFromContainer Feature(NotificationChain)
line: 252
AktivitaetImpl(BasicEObjectImpl).eBasicRemoveFromContainer(N otificationChain)
line: 1366
AktivitaetImpl(BasicEObjectImpl).eSetResource(Resource$Inter nal,
NotificationChain) line: 972
ResourceImpl$ContentsEList<E>.inverseRemove(E, NotificationChain) line: 386
ResourceImpl$ContentsEList<E>(NotifyingListImpl<E>).clear() line: 1092
HibernateResource(ResourceImpl).doUnload() line: 1472
HibernateResource(StoreResource).doUnload() line: 370
HibernateResource.doUnload() line: 410
HibernateResource(ResourceImpl).unload() line: 1494
This is because the resource.contents has not only the root object
(ProzessImpl) in its data list but also the child object (AktivitaetImpl).
I noticed that before but did not realize that this could be wrong. I
thought the data list would contain all objects. But it is wrong, isn't it?
I fear that the problem we discussed here
http://www.eclipse.org/newsportal/article.php?id=4805&gr oup=eclipse.technology.emft#4805
comes back in a new flavour. I did not verify this but I guess the loading
of the xml diagram resource puts the child object as another root object
into the resource. I'll debug it as soon as possible, but it could last a
few days ...
gr. Manfred
|
|
|
Re: [Teneo] Unload() questions [message #118658 is a reply to message #118415] |
Wed, 16 April 2008 07:26 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Manfred,
Yes the clear and resulting remove from the container seems standard EMF and correct behavior if the
objects are in the root of the resource.
The question is how the object ended up in the root of the resource. If you debug then a good place
to put a breakpoint is in the attached* methods in the StoreResource. These are called when a new
object is added to the resource.
As a side remark.
Even if, in your case, there is an underlying solvable issue, then it is possible with a
hibernateresource to load parents and childs in the top of the resource. This can be done using
queries. In that case the same side-effect will occur. So afaics a hibernateresource should be
changed to do clear without any inverseremovals.
gr. Martin
Manfred Hahn wrote:
> Hi Martin,
>
> I've debugged the unload() and came to the following stack:
> ProzessImpl.eInverseRemove(InternalEObject, int, NotificationChain)
> line: 245
> ProzessImpl(BasicEObjectImpl).eInverseRemove(InternalEObject , int,
> Class<?>, NotificationChain) line: 1421
> AktivitaetImpl(ProzessElementImpl).eBasicRemoveFromContainer Feature(NotificationChain)
> line: 252
> AktivitaetImpl(BasicEObjectImpl).eBasicRemoveFromContainer(N otificationChain)
> line: 1366
> AktivitaetImpl(BasicEObjectImpl).eSetResource(Resource$Inter nal,
> NotificationChain) line: 972
> ResourceImpl$ContentsEList<E>.inverseRemove(E, NotificationChain) line:
> 386
> ResourceImpl$ContentsEList<E>(NotifyingListImpl<E>).clear() line: 1092
> HibernateResource(ResourceImpl).doUnload() line: 1472
> HibernateResource(StoreResource).doUnload() line: 370
> HibernateResource.doUnload() line: 410
> HibernateResource(ResourceImpl).unload() line: 1494
>
> This is because the resource.contents has not only the root object
> (ProzessImpl) in its data list but also the child object
> (AktivitaetImpl). I noticed that before but did not realize that this
> could be wrong. I thought the data list would contain all objects. But
> it is wrong, isn't it?
>
> I fear that the problem we discussed here
>
> http://www.eclipse.org/newsportal/article.php?id=4805&gr oup=eclipse.technology.emft#4805
>
>
> comes back in a new flavour. I did not verify this but I guess the
> loading of the xml diagram resource puts the child object as another
> root object into the resource. I'll debug it as soon as possible, but it
> could last a few days ...
>
> gr. Manfred
>
--
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] Unload() questions [message #616234 is a reply to message #117967] |
Sat, 12 April 2008 20:43 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Manfred,
Fmi, which version of Teneo are you using?
The unload clears the resource but it should not result in any database actions. During the clear of
the resource contents the detached method is called which calls detachedHelper which calls
removedEObject. However these methods don't do much more than putting the objects in the
deletedObjects array and removing them from the newobjects/loadedobjects arrays. As long as save is
not called this should not result in actually removing the objects from the db. What you can do is
enabled hibernate logging and see if hibernate logs any actions during the unload.
Can you let me know what you find here?
To fight the symptom what you can do is set the hibernate flushmode to commit. So then hibernate
will only flush changes to the db when you call an explicit commit on the transaction. But this will
only solve the symptom and not the underlying cause...
I can imagine that you need to save the hibernate resource before the separate gmf xml resource
because otherwise the references from the gmf resource to the (hibernate) objects can't use the
primary keys.
Note a difference between your approach and the approach in the teneo-gmf tutorial is that in the
tutorial I use one resource for both the diagram and the model data.
gr. Martin
Manfred Hahn wrote:
> Hi Martin,
>
> I have a question concerning the unload() function. When I started to
> work with Teneo, I put the GMF model into the hibernate database as you
> did in your GMF tutorial. I had some "java.lang.IllegalStateException:
> Cannot modify resource set without a write transaction" notes in the
> .log file during unload, so I put an EMF transaction and a Hibernate
> transaction around the unload() statement in
> XxxDocumentProvider$ResourceSetInfo.dispose(). The exceptions in .log
> where gone.
>
> Now I decided to go a step back and use the XML representation of the
> GMF model, leaving the logical model in the hibernate database. (In fact
> I put the XML representation in a blob field of the database. I wrote a
> special URL handling in the way I had seen in Teneo to manage that.)
> But then I discoverd that the model storage seemed to behave in an
> unpredictable way: sometimes objects vanished from the model after
> storing and reloading. I found out that hibernate deleted objects during
> the unload of the resource because they had been marked as orphaned.
> Every child object that had been loaded from the database was deleted;
> newly created child objects were stored in the database. The reason for
> this I don't know exactly but I think the clearing of the resource
> contents has something to do with it and the splitting of the resource
> types. Just to be shure that my URL handling is not buggy I changed it
> to a real file URL for the GMF model. The problems were the same.
>
> So I changed the XxxDocumentProvider$ResourceSetInfo.dispose() back to
> its original. Now the database problems are gone but the "Cannot modify
> resource set.." exception is again in the .log file.
>
> I manage the hibernate session with one session controller. I have no
> open transactions when the application is closed. All database storage
> actions are done in the doSave() method. So I expect the unload()
> function to do nothing on the database.
>
> These are my questions: What database actions are expected to be done
> during unload()? Should there be an EMF and hibernate transaction open?
> Do I have to do something special during unload with my two resource
> type, e.g. unloading them in a special sequence? (I had to do this in
> doSave() to ensure that the primary keys are set when I store the XML
> GMF resource)
>
> Best regards
> Manfred
>
>
--
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] Unload() questions [message #616287 is a reply to message #117994] |
Mon, 14 April 2008 11:29 |
Manfred Hahn Messages: 64 Registered: July 2009 |
Member |
|
|
Hi Martin,
my Teneo version is 0.8.0.v200804061007
In the meantime I have a solution, but no understanding..;-)
This is the scenario:
Loading of a model with one root object and one child. (And another root
object in another resource, to be honest)
Storing the model with "save" (without any previous or later changes).
Closing the program.
When I have the original dispose() method, the unload does a .log entry:
!MESSAGE Cannot modify resource set without a write transaction
!STACK 0
java.lang.IllegalStateException: Cannot modify resource set without a
write transaction
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:322)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:284)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:266)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:222)
at
org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:247)
at
org.eclipse.emf.common.notify.impl.NotificationImpl.dispatch (NotificationImpl.java:1030)
at
org.eclipse.emf.common.notify.impl.NotifyingListImpl.clear(N otifyingListImpl.java:1101)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.doUnload(Re sourceImpl.java:1472)
at
org.eclipse.emf.teneo.resource.StoreResource.doUnload(StoreR esource.java:370)
at
org.eclipse.emf.teneo.hibernate.resource.HibernateResource.d oUnload(HibernateResource.java:410)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.unload(Reso urceImpl.java:1494)
at
de.edvchl.clic.workflow.diagram.part.WorkflowDocumentProvide r$ResourceSetInfo.dispose(WorkflowDocumentProvider.java:732)
So I changed the dispose() function like this:
public void dispose() {
getResourceSet().eAdapters().remove(myResourceSetListener);
TransactionalEditingDomain editingDomain = getEditingDomain();
final EditingDomainHandler handler =
EditingDomainHandler.getEditingDomainHandler();
Command cmd = new RecordingCommand(editingDomain){
@Override
protected void doExecute() {
handler.getSessionController().getSessionWrapper().beginTran saction();
try {
for (Resource resource : getResourceSet().getResources()) {
resource.unload();
}
handler.getSessionController().getSessionWrapper().commitTra nsaction();
}
catch (RuntimeException e) {
handler.getSessionController().getSessionWrapper().rollbackT ransaction();
throw e;
}
}
};
editingDomain.getCommandStack().execute(cmd);
}
(The handler is just a simple helper class to get always the one and only
SessionController)
The unload() has no more Exceptions, but the log4j-log shows:
136736 [main] DEBUG
org.eclipse.emf.teneo.hibernate.resource.HibernateResource - Doing
unload, has session controller, sessioncontroller is therefor responsible
for session close
136746 [main] DEBUG
org.eclipse.emf.teneo.hibernate.resource.HibernateResource - Doing
unload, has session controller, sessioncontroller is therefor responsible
for session close
136746 [main] DEBUG org.hibernate.transaction.JDBCTransaction - commit
136746 [main] DEBUG org.hibernate.impl.SessionImpl - automatically
flushing session
136746 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener
- flushing session
136746 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener
- processing flush-time cascades
136746 [main] DEBUG org.hibernate.engine.Cascade - processing cascade
ACTION_SAVE_UPDATE for: Prozess
136746 [main] DEBUG org.hibernate.engine.Cascade - cascade
ACTION_SAVE_UPDATE for collection: Prozess.elemente
136746 [main] DEBUG org.hibernate.engine.Cascade - done cascade
ACTION_SAVE_UPDATE for collection: Prozess.elemente
136746 [main] DEBUG org.hibernate.engine.Cascade - deleting orphans for
collection: Prozess.elemente
136746 [main] DEBUG org.hibernate.engine.Cascade - deleting orphaned
entity instance: ProzessElement
136756 [main] DEBUG org.hibernate.event.def.DefaultDeleteEventListener -
deleting a persistent instance
136756 [main] DEBUG org.hibernate.event.def.DefaultDeleteEventListener -
deleting [Aktivitaet#402884e9194c8ec501194c90f7fe0004]
So my only child object has been deleted!
My solution is, to do an EMF transaction without a hibernate transaction.
Then everything is ok, no more exception and no deletes.
What is wrong with the hibernate transaction?
The previous save shows a clean flush without any changes in the database.
gr. Manfred
|
|
|
Re: [Teneo] Unload() questions [message #616294 is a reply to message #118295] |
Mon, 14 April 2008 17:58 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Manfred,
It seems that the unload removes the child from the parent collection. To be sure can you try/check
the following:
- is the child present in the collection before the unload?
- is the child present in the collection after the unload but before the commit?
gr. Martin
Manfred Hahn wrote:
> Hi Martin,
>
> my Teneo version is 0.8.0.v200804061007
>
> In the meantime I have a solution, but no understanding..;-)
>
> This is the scenario:
> Loading of a model with one root object and one child. (And another root
> object in another resource, to be honest)
> Storing the model with "save" (without any previous or later changes).
> Closing the program.
>
> When I have the original dispose() method, the unload does a .log entry:
>
> !MESSAGE Cannot modify resource set without a write transaction
> !STACK 0
> java.lang.IllegalStateException: Cannot modify resource set without a
> write transaction
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:322)
>
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:284)
>
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:266)
>
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:222)
>
> at
> org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:247)
>
> at
> org.eclipse.emf.common.notify.impl.NotificationImpl.dispatch (NotificationImpl.java:1030)
>
> at
> org.eclipse.emf.common.notify.impl.NotifyingListImpl.clear(N otifyingListImpl.java:1101)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.doUnload(Re sourceImpl.java:1472)
>
> at
> org.eclipse.emf.teneo.resource.StoreResource.doUnload(StoreR esource.java:370)
>
> at
> org.eclipse.emf.teneo.hibernate.resource.HibernateResource.d oUnload(HibernateResource.java:410)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.unload(Reso urceImpl.java:1494)
>
> at
> de.edvchl.clic.workflow.diagram.part.WorkflowDocumentProvide r$ResourceSetInfo.dispose(WorkflowDocumentProvider.java:732)
>
>
>
> So I changed the dispose() function like this:
>
> public void dispose() {
> getResourceSet().eAdapters().remove(myResourceSetListener);
> TransactionalEditingDomain editingDomain = getEditingDomain();
> final EditingDomainHandler handler =
> EditingDomainHandler.getEditingDomainHandler();
> Command cmd = new RecordingCommand(editingDomain){
>
> @Override
> protected void doExecute() {
>
> handler.getSessionController().getSessionWrapper().beginTran saction();
> try {
> for (Resource resource :
> getResourceSet().getResources()) {
> resource.unload();
> }
>
> handler.getSessionController().getSessionWrapper().commitTra nsaction();
> }
> catch (RuntimeException e) {
>
> handler.getSessionController().getSessionWrapper().rollbackT ransaction();
> throw e;
> }
> }
>
> };
> editingDomain.getCommandStack().execute(cmd);
> }
>
>
> (The handler is just a simple helper class to get always the one and
> only SessionController)
>
> The unload() has no more Exceptions, but the log4j-log shows:
> 136736 [main] DEBUG
> org.eclipse.emf.teneo.hibernate.resource.HibernateResource - Doing
> unload, has session controller, sessioncontroller is therefor
> responsible for session close
> 136746 [main] DEBUG
> org.eclipse.emf.teneo.hibernate.resource.HibernateResource - Doing
> unload, has session controller, sessioncontroller is therefor
> responsible for session close
> 136746 [main] DEBUG org.hibernate.transaction.JDBCTransaction - commit
> 136746 [main] DEBUG org.hibernate.impl.SessionImpl - automatically
> flushing session
> 136746 [main] DEBUG
> org.hibernate.event.def.AbstractFlushingEventListener - flushing session
> 136746 [main] DEBUG
> org.hibernate.event.def.AbstractFlushingEventListener - processing
> flush-time cascades
> 136746 [main] DEBUG org.hibernate.engine.Cascade - processing cascade
> ACTION_SAVE_UPDATE for: Prozess
> 136746 [main] DEBUG org.hibernate.engine.Cascade - cascade
> ACTION_SAVE_UPDATE for collection: Prozess.elemente
> 136746 [main] DEBUG org.hibernate.engine.Cascade - done cascade
> ACTION_SAVE_UPDATE for collection: Prozess.elemente
> 136746 [main] DEBUG org.hibernate.engine.Cascade - deleting orphans for
> collection: Prozess.elemente
> 136746 [main] DEBUG org.hibernate.engine.Cascade - deleting orphaned
> entity instance: ProzessElement
> 136756 [main] DEBUG org.hibernate.event.def.DefaultDeleteEventListener
> - deleting a persistent instance
> 136756 [main] DEBUG org.hibernate.event.def.DefaultDeleteEventListener
> - deleting [Aktivitaet#402884e9194c8ec501194c90f7fe0004]
>
>
> So my only child object has been deleted!
>
> My solution is, to do an EMF transaction without a hibernate transaction.
> Then everything is ok, no more exception and no deletes.
>
> What is wrong with the hibernate transaction?
> The previous save shows a clean flush without any changes in the database.
>
> gr. Manfred
>
--
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] Unload() questions [message #616307 is a reply to message #118377] |
Tue, 15 April 2008 13:01 |
Ed Merks Messages: 33141 Registered: July 2009 |
Senior Member |
|
|
Martin,
I know solve folks specialize the unload behavior to decompose the
containment structure of the unloaded tree of objects. That's not the
default behavior though...
Martin Taal wrote:
> Hi Manfred,
> I tested the unload and in my case the children remain in the parent
> (I tested using the Library/Book/Writer example). In your case I don't
> know which eventlistener causes the remove of the child. So the only
> option is to debug through the unload action and see what happens.
>
> gr. Martin
>
> Manfred Hahn wrote:
>> Hi Martin,
>>
>> yes, you are right! Before the unload everything is ok, but after the
>> unload the resource is empty (I expected this) and the model root
>> element has lost its child (I didn't expect this).
>> Is there a chain of events / event listeners that do this change
>> during the clearing of the resource contents list?
>>
>> gr. Manfred
>>
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: [Teneo] Unload() questions [message #616313 is a reply to message #118377] |
Tue, 15 April 2008 15:01 |
Manfred Hahn Messages: 64 Registered: July 2009 |
Member |
|
|
Hi Martin,
I've debugged the unload() and came to the following stack:
ProzessImpl.eInverseRemove(InternalEObject, int, NotificationChain) line:
245
ProzessImpl(BasicEObjectImpl).eInverseRemove(InternalEObject , int,
Class<?>, NotificationChain) line: 1421
AktivitaetImpl(ProzessElementImpl).eBasicRemoveFromContainer Feature(NotificationChain)
line: 252
AktivitaetImpl(BasicEObjectImpl).eBasicRemoveFromContainer(N otificationChain)
line: 1366
AktivitaetImpl(BasicEObjectImpl).eSetResource(Resource$Inter nal,
NotificationChain) line: 972
ResourceImpl$ContentsEList<E>.inverseRemove(E, NotificationChain) line: 386
ResourceImpl$ContentsEList<E>(NotifyingListImpl<E>).clear() line: 1092
HibernateResource(ResourceImpl).doUnload() line: 1472
HibernateResource(StoreResource).doUnload() line: 370
HibernateResource.doUnload() line: 410
HibernateResource(ResourceImpl).unload() line: 1494
This is because the resource.contents has not only the root object
(ProzessImpl) in its data list but also the child object (AktivitaetImpl).
I noticed that before but did not realize that this could be wrong. I
thought the data list would contain all objects. But it is wrong, isn't it?
I fear that the problem we discussed here
http://www.eclipse.org/newsportal/article.php?id=4805&gr oup=eclipse.technology.emft#4805
comes back in a new flavour. I did not verify this but I guess the loading
of the xml diagram resource puts the child object as another root object
into the resource. I'll debug it as soon as possible, but it could last a
few days ...
gr. Manfred
|
|
|
Re: [Teneo] Unload() questions [message #617771 is a reply to message #118415] |
Wed, 16 April 2008 07:26 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Manfred,
Yes the clear and resulting remove from the container seems standard EMF and correct behavior if the
objects are in the root of the resource.
The question is how the object ended up in the root of the resource. If you debug then a good place
to put a breakpoint is in the attached* methods in the StoreResource. These are called when a new
object is added to the resource.
As a side remark.
Even if, in your case, there is an underlying solvable issue, then it is possible with a
hibernateresource to load parents and childs in the top of the resource. This can be done using
queries. In that case the same side-effect will occur. So afaics a hibernateresource should be
changed to do clear without any inverseremovals.
gr. Martin
Manfred Hahn wrote:
> Hi Martin,
>
> I've debugged the unload() and came to the following stack:
> ProzessImpl.eInverseRemove(InternalEObject, int, NotificationChain)
> line: 245
> ProzessImpl(BasicEObjectImpl).eInverseRemove(InternalEObject , int,
> Class<?>, NotificationChain) line: 1421
> AktivitaetImpl(ProzessElementImpl).eBasicRemoveFromContainer Feature(NotificationChain)
> line: 252
> AktivitaetImpl(BasicEObjectImpl).eBasicRemoveFromContainer(N otificationChain)
> line: 1366
> AktivitaetImpl(BasicEObjectImpl).eSetResource(Resource$Inter nal,
> NotificationChain) line: 972
> ResourceImpl$ContentsEList<E>.inverseRemove(E, NotificationChain) line:
> 386
> ResourceImpl$ContentsEList<E>(NotifyingListImpl<E>).clear() line: 1092
> HibernateResource(ResourceImpl).doUnload() line: 1472
> HibernateResource(StoreResource).doUnload() line: 370
> HibernateResource.doUnload() line: 410
> HibernateResource(ResourceImpl).unload() line: 1494
>
> This is because the resource.contents has not only the root object
> (ProzessImpl) in its data list but also the child object
> (AktivitaetImpl). I noticed that before but did not realize that this
> could be wrong. I thought the data list would contain all objects. But
> it is wrong, isn't it?
>
> I fear that the problem we discussed here
>
> http://www.eclipse.org/newsportal/article.php?id=4805&gr oup=eclipse.technology.emft#4805
>
>
> comes back in a new flavour. I did not verify this but I guess the
> loading of the xml diagram resource puts the child object as another
> root object into the resource. I'll debug it as soon as possible, but it
> could last a few days ...
>
> gr. Manfred
>
--
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
|
|
| | |
Goto Forum:
Current Time: Fri Apr 26 03:38:18 GMT 2024
Powered by FUDForum. Page generated in 0.05342 seconds
|