Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » teneo - cross resource references (only into HbResource)
teneo - cross resource references (only into HbResource) [message #61160] Mon, 13 November 2006 22:29 Go to next message
Andre Pareis is currently offline Andre PareisFriend
Messages: 113
Registered: July 2009
Senior Member
Hi Martin,

it's me again, with another thing from my wish list ;)

Let's say I want to separate my model into a small part which lives in an XML
resource and a large part which shall go into a relational data store. Could
teneo handle uni-directional references from the XML into the StoreResource? I
know that it will be very hard to accomplish that in the other direction or for
bidirectional associations, because you would have to replace the foreign key
concept with some "real foreign" (which would perhaps be possible by adding a
second, "external" FK which is just a URL and you could denote that on the model
by saying something is "remotable" for instance. But that too much, I know. Back
to the initial question: woudl such a simple linking work? Can the StoreResource
or HbResource provide the XML resource a reasonable URI fragment which can
later be used to retrieve the object? This could be a class+ID or a full blown
query.

The current fragment of an object just looks like a normal XML one, for example:
"//@clients.0/@vendors.1/@optionSources.0" - I assume teneo will at the moment
not be able to handle this and IIRC I made some tests a while ago and they failed.

Is it possible to provide a meaningful implementation of the URI fragment
together with it's resolution later? I'm very interested in your answer and for
this thing, I would definitely enter an enhancement request :)

Regards
Andre
Re: teneo - cross resource references (only into HbResource) [message #61208 is a reply to message #61160] Tue, 14 November 2006 07:57 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Andre,
This is not impossible. As a default already a basic form should work. However this basic form is
not very practical (or only limited practical). Currently the references from the xml to the
relational resource will have the form of (see the href):
<library:Writer xmlns:library="http://www.eclipse.org/emf/teneo/samples/emf/sample/Library"
name="JRR Tolkien">
<books href=" hibernate://?dsname=LibraryResourceAction_mysql_s_o#//@books .0"/>
<books href=" hibernate://?dsname=LibraryResourceAction_mysql_s_o#//@books .1"/>
</library:Writer>

This works, so when opening the xml the references to the book are resolved and the book is read
from the db through the hibernate resource. (note that the xml needs to be read through a resource
created in a resourceset, this same resourceset, also the xmlresourcefactory needs to be registered,
if you use xml)
However the references are relative, if the position of the books change then the xml is not valid
anymore. Although (ofcourse) no referential constraints are enforced between xml and the rdb,
relative hrefs are more sensitive then id-based direct references.

Btw, see also here:
http://eclipsezone.com/eclipse/forums/t80113.html

A solution would be to use the ID concept of emf. For example if the title of the book is set to
ID=true then the xml would look like:
<library:Writer name="JRR Tolkien">
<books href=" hibernate://?dsname=LibraryResourceAction_mysql_s_o#Fellowsh ip of the Ring"/>
<books href="hibernate://?dsname=LibraryResourceAction_mysql_s_o#The Hobbit"/>
</library:Writer>

This almost works, what happens, is that the correct resource is created (using the
hibernate://?dsname url) and then EMF will call getObjectByID on this hibernateresource using the
title part (for example The Hobbit). However the current HibernateResource (or jpoxresource) does
not implement the getObjectById method and so does not read from the db. Even if the
hibernateresource would implement the getObjectByID method then also the expected type (eclass)
should be encoded in the id, otherwise Hibernate does not know what to read (The Hobbit can also be
a writer).
In addition for this to work the EObject needs one EAttribute which has ID=true. The ID should be
the combination of the eclass name and the id of the object.
Also the id of the object needs to be convertable to a string.

What I am currently thinking of is:
Implement a utility method convertToEmfId(Session, EObject) which creates a String id with the
eclass and hibernate (or jpox) id encoded in it.

This method can be used by the developer to implement the id attribute (the eattribute with ID=true).
Then implement the getObjectById method in HibernateResource (and jpoxresource) which assumes an id
of the format created by the utility method. This method uses the eclass and id encoded in the
string id to read the object from the db.

This solution requires each eclass (for which references between xml and rdb are important) to have
a computed ID attribute (using this utility method).

Would this work in your situation?

gr. Martin

Andre Pareis wrote:
> Hi Martin,
>
> it's me again, with another thing from my wish list ;)
>
> Let's say I want to separate my model into a small part which lives in
> an XML resource and a large part which shall go into a relational data
> store. Could teneo handle uni-directional references from the XML into
> the StoreResource? I know that it will be very hard to accomplish that
> in the other direction or for bidirectional associations, because you
> would have to replace the foreign key concept with some "real foreign"
> (which would perhaps be possible by adding a second, "external" FK which
> is just a URL and you could denote that on the model by saying something
> is "remotable" for instance. But that too much, I know. Back to the
> initial question: woudl such a simple linking work? Can the
> StoreResource or HbResource provide the XML resource a reasonable URI
> fragment which can later be used to retrieve the object? This could be a
> class+ID or a full blown query.
>
> The current fragment of an object just looks like a normal XML one, for
> example: "//@clients.0/@vendors.1/@optionSources.0" - I assume teneo
> will at the moment not be able to handle this and IIRC I made some tests
> a while ago and they failed.
>
> Is it possible to provide a meaningful implementation of the URI
> fragment together with it's resolution later? I'm very interested in
> your answer and for this thing, I would definitely enter an enhancement
> request :)
>
> Regards
> Andre
>


--

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 - cross resource references (only into HbResource) [message #595569 is a reply to message #61160] Tue, 14 November 2006 07:57 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Andre,
This is not impossible. As a default already a basic form should work. However this basic form is
not very practical (or only limited practical). Currently the references from the xml to the
relational resource will have the form of (see the href):
<library:Writer xmlns:library="http://www.eclipse.org/emf/teneo/samples/emf/sample/Library"
name="JRR Tolkien">
<books href=" hibernate://?dsname=LibraryResourceAction_mysql_s_o#//@books .0"/>
<books href=" hibernate://?dsname=LibraryResourceAction_mysql_s_o#//@books .1"/>
</library:Writer>

This works, so when opening the xml the references to the book are resolved and the book is read
from the db through the hibernate resource. (note that the xml needs to be read through a resource
created in a resourceset, this same resourceset, also the xmlresourcefactory needs to be registered,
if you use xml)
However the references are relative, if the position of the books change then the xml is not valid
anymore. Although (ofcourse) no referential constraints are enforced between xml and the rdb,
relative hrefs are more sensitive then id-based direct references.

Btw, see also here:
http://eclipsezone.com/eclipse/forums/t80113.html

A solution would be to use the ID concept of emf. For example if the title of the book is set to
ID=true then the xml would look like:
<library:Writer name="JRR Tolkien">
<books href=" hibernate://?dsname=LibraryResourceAction_mysql_s_o#Fellowsh ip of the Ring"/>
<books href="hibernate://?dsname=LibraryResourceAction_mysql_s_o#The Hobbit"/>
</library:Writer>

This almost works, what happens, is that the correct resource is created (using the
hibernate://?dsname url) and then EMF will call getObjectByID on this hibernateresource using the
title part (for example The Hobbit). However the current HibernateResource (or jpoxresource) does
not implement the getObjectById method and so does not read from the db. Even if the
hibernateresource would implement the getObjectByID method then also the expected type (eclass)
should be encoded in the id, otherwise Hibernate does not know what to read (The Hobbit can also be
a writer).
In addition for this to work the EObject needs one EAttribute which has ID=true. The ID should be
the combination of the eclass name and the id of the object.
Also the id of the object needs to be convertable to a string.

What I am currently thinking of is:
Implement a utility method convertToEmfId(Session, EObject) which creates a String id with the
eclass and hibernate (or jpox) id encoded in it.

This method can be used by the developer to implement the id attribute (the eattribute with ID=true).
Then implement the getObjectById method in HibernateResource (and jpoxresource) which assumes an id
of the format created by the utility method. This method uses the eclass and id encoded in the
string id to read the object from the db.

This solution requires each eclass (for which references between xml and rdb are important) to have
a computed ID attribute (using this utility method).

Would this work in your situation?

gr. Martin

Andre Pareis wrote:
> Hi Martin,
>
> it's me again, with another thing from my wish list ;)
>
> Let's say I want to separate my model into a small part which lives in
> an XML resource and a large part which shall go into a relational data
> store. Could teneo handle uni-directional references from the XML into
> the StoreResource? I know that it will be very hard to accomplish that
> in the other direction or for bidirectional associations, because you
> would have to replace the foreign key concept with some "real foreign"
> (which would perhaps be possible by adding a second, "external" FK which
> is just a URL and you could denote that on the model by saying something
> is "remotable" for instance. But that too much, I know. Back to the
> initial question: woudl such a simple linking work? Can the
> StoreResource or HbResource provide the XML resource a reasonable URI
> fragment which can later be used to retrieve the object? This could be a
> class+ID or a full blown query.
>
> The current fragment of an object just looks like a normal XML one, for
> example: "//@clients.0/@vendors.1/@optionSources.0" - I assume teneo
> will at the moment not be able to handle this and IIRC I made some tests
> a while ago and they failed.
>
> Is it possible to provide a meaningful implementation of the URI
> fragment together with it's resolution later? I'm very interested in
> your answer and for this thing, I would definitely enter an enhancement
> request :)
>
> Regards
> Andre
>


--

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 and volume data
Next Topic:How to declare type of empty collection in OCL?
Goto Forum:
  


Current Time: Fri Feb 26 10:52:47 GMT 2021

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

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

Back to the top