Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [TEXO] traverse object graph
[TEXO] traverse object graph [message #873587] Fri, 18 May 2012 15:41 Go to next message
Gary Godfrey is currently offline Gary GodfreyFriend
Messages: 31
Registered: February 2012
Member
Hi,

Is there a way to traverse back up through the JPA annotated TEXO generated domain model?

e.g.
Application (id, channel, product)
--->Applicant(s) (id, first name, last name, type)
------>Address(s) (id, line1, line2, type)


The data is persisted to the datastore fine. JPA adds parent id column to the child tables when the schema is auto-generated.

I now have the challenge of querying the data. The user wants the following data returned:
application.id, application.channel, address.line1, applicant.firstname where address.type = "home" and applicant.type = "gold";


The equivalent SQL would be something like this; joining to each parent table to get the attributes required:
select a.id, a.channel, b.firstname, c.line1,  from Application a, Applicant b, Address c where c.type = "home"
and b.type = "gold"
and c.id = b.id
and b.id = a.id;


I can use the ModelPackage to validate that address.line1 is a valid EAttribute. I cannot though see how I can traverse back up the object graph to find the parent structure right up to my top-level domain object. Is this possible?

Thanks,
Gary
Re: [TEXO] traverse object graph [message #873598 is a reply to message #873587] Fri, 18 May 2012 16:08 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Gary,
You have to explicitly model the pointer to the parent in your model, you can make the association bidirectional. Texo
should map this correctly. See also this wiki page:
http://wiki.eclipse.org/Texo/Code_Generation_Patterns#Generation_of_a_safe_bi-directional_association_API_.28or_not.29

gr. Martin


On 05/18/2012 05:41 PM, Gary Godfrey wrote:
> Hi,
>
> Is there a way to traverse back up through the JPA annotated TEXO generated domain model?
>
> e.g.
>
> Application (id, channel, product)
> --->Applicant(s) (id, first name, last name, type)
> ------>Address(s) (id, line1, line2, type)
>
>
> The data is persisted to the datastore fine. JPA adds parent id column to the child tables when the schema is
> auto-generated.
>
> I now have the challenge of querying the data. The user wants the following data returned:
>
> application.id, application.channel, address.line1, applicant.firstname where address.type = "home" and applicant.type =
> "gold";
>
>
> The equivalent SQL would be something like this; joining to each parent table to get the attributes required:
>
> select a.id, a.channel, b.firstname, c.line1, from Application a, Applicant b, Address c where c.type = "home"
> and b.type = "gold"
> and c.id = b.id
> and b.id = a.id;
>
>
> I can use the ModelPackage to validate that address.line1 is a valid EAttribute. I cannot though see how I can traverse
> back up the object graph to find the parent structure right up to my top-level domain object. Is this possible?
>
> Thanks,
> Gary


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Previous Topic:Texo: list of annoying details
Next Topic:[JET] "translation" code
Goto Forum:
  


Current Time: Tue Apr 16 20:28:28 GMT 2024

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

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

Back to the top