Home » Modeling » EMF » [Teneo, GMF] Notes from hibernate have model element attached
[Teneo, GMF] Notes from hibernate have model element attached [message #513454] |
Wed, 10 February 2010 05:00 |
Markus Franz Messages: 38 Registered: July 2009 |
Member |
|
|
Hi all,
in our GMF(2.2.1)/Teneo(1.1.2)/Hibernate(3.3.2) application we tried to
use the GMF notes features ("Add note" from diagram context menu) as the
bug pestering us before
(https://bugs.eclipse.org/bugs/show_bug.cgi?id=280040) was resolved some
time ago, this should not be that big a problem, however it is. Has
anyone ever used Teneo with a GMF editor and was able to properly handle
"Note"s?
Problem now is: A NoteEditPart does (as i understand it anyway) NOT have
a model element attached (it's just some annotation, maybe associated
with a model object representation via a connection). Now with
aforementioned bug fixed, i am able to add notes, persist everything and
even load it again. But after loading a diagram with notes, those Note
views have a mdel element attached! To make this a bit clearer, i am
using the GMF/Teneo tutorial (good ol' Mindmap) as example: use the
GMF/Teneo example from CVS, add some topic (not required) and some
note(s) via context menu. Note is displayed (and has no model element
associated which is crucial!) and may be persisted. Now close Editor,
open again, and load diagram. Now the "note" nodes have the map (!)
associated as model element, which would then mean that deleting a note
would delete the map (which will not work, as hibernate realizes that th
"deleted element" (map) "would be resaved by cascade" (or something like
that) because it is the model element of the diagram itself...
I have no idea, why persisted Notes will get the root model element as
element, but this is preventing the use of "Note"s in Teneo/GMF
applications.
Any insights?
Markus
|
|
|
Re: [Teneo, GMF] Notes from hibernate have model element attached [message #513526 is a reply to message #513454] |
Wed, 10 February 2010 13:39 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Markus,
I don't use GMF myself so that makes it difficult to know all the details...
To analyse the issue some more it is best to debug when the model element gets attached. Is this when saving or when
reading from the database?
Can you put a (conditional) breakpoint in the getter/setter and eGet/eSet methods of the Note object? And check the
stacktrace when the modelelement is set?
gr. Martin
Markus Franz wrote:
> Hi all,
>
> in our GMF(2.2.1)/Teneo(1.1.2)/Hibernate(3.3.2) application we tried to
> use the GMF notes features ("Add note" from diagram context menu) as the
> bug pestering us before
> (https://bugs.eclipse.org/bugs/show_bug.cgi?id=280040) was resolved some
> time ago, this should not be that big a problem, however it is. Has
> anyone ever used Teneo with a GMF editor and was able to properly handle
> "Note"s?
> Problem now is: A NoteEditPart does (as i understand it anyway) NOT have
> a model element attached (it's just some annotation, maybe associated
> with a model object representation via a connection). Now with
> aforementioned bug fixed, i am able to add notes, persist everything and
> even load it again. But after loading a diagram with notes, those Note
> views have a mdel element attached! To make this a bit clearer, i am
> using the GMF/Teneo tutorial (good ol' Mindmap) as example: use the
> GMF/Teneo example from CVS, add some topic (not required) and some
> note(s) via context menu. Note is displayed (and has no model element
> associated which is crucial!) and may be persisted. Now close Editor,
> open again, and load diagram. Now the "note" nodes have the map (!)
> associated as model element, which would then mean that deleting a note
> would delete the map (which will not work, as hibernate realizes that th
> "deleted element" (map) "would be resaved by cascade" (or something like
> that) because it is the model element of the diagram itself...
> I have no idea, why persisted Notes will get the root model element as
> element, but this is preventing the use of "Note"s in Teneo/GMF
> applications.
>
> Any insights?
>
> Markus
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
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, GMF] Notes from hibernate have model element attached [message #513583 is a reply to message #513576] |
Wed, 10 February 2010 15:48 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Markus,
No idea really why gmf has this code...
But to prevent this from influencing the persistence logic you can try to annotate the efeature with @Transient then it
won't be persisted.
gr. Martin
Markus Franz wrote:
> Hi Martin,
>
> i found the problematic piece of code. I looked in the database after
> persisting, and there all seems to be in order (i.e. the "Note" EObject
> has no element). After loading in the ViewImpl.getElement() method, the
> following sets the element (if not set) to the parent's model element:
>
>
> if (!isSetElement()) {
> EObject container = eContainer();
> if (container instanceof View) {
> View view = (View) container;
> element = view.getElement();
> }
> }
>
> As to why this might make sense i have no idea...
> Maybe i should ask in the GMF Group, if you have no further guess.
>
> Markus
>
> Martin Taal schrieb:
>> Hi Markus,
>> I don't use GMF myself so that makes it difficult to know all the
>> details...
>>
>> To analyse the issue some more it is best to debug when the model
>> element gets attached. Is this when saving or when reading from the
>> database?
>> Can you put a (conditional) breakpoint in the getter/setter and
>> eGet/eSet methods of the Note object? And check the stacktrace when
>> the modelelement is set?
>>
>> gr. Martin
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
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 15:30:00 GMT 2024
Powered by FUDForum. Page generated in 0.03444 seconds
|