Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » OneToOne mapping on same table
OneToOne mapping on same table [message #631443] Thu, 07 October 2010 14:47 Go to next message
Matti Hansson is currently offline Matti Hansson
Messages: 68
Registered: July 2009
Member
Hi!
I have an object model with a Unit having a one-to-one relation to a UnitIdentifier. In the database, all fields of both classes are contained within a single table.

It's easy enough to simply map those classes like usual and call it a day, but this will result in two queries to the database: select the fields of Unit in the correct row, and then select the fields of UnitIdentifier in the same row.

This is fine, I guess, but it makes me hurt a bit inside Razz
Is there a way to do this using a single fetch?

Thanks!
/Matti
Re: OneToOne mapping on same table [message #631699 is a reply to message #631443] Fri, 08 October 2010 13:59 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1023
Registered: July 2009
Senior Member
EclipseLink has a @JoinFetch annotation you can used on a relationship, or you can use fetch join in JPQL for particular relationships. What is the table and entity setup for these two classes? Do they share a row, are they using inheritance, etc?

Best Regards,
Chris
Re: OneToOne mapping on same table [message #632019 is a reply to message #631443] Mon, 11 October 2010 08:49 Go to previous message
Matti Hansson is currently offline Matti Hansson
Messages: 68
Registered: July 2009
Member
Thanks for the reply, Chris, but @JoinFetch was not quite what I was after. However, I found that @Embeddable/@Embedded does exactly what I want.
Problem solved.
/Matti
Previous Topic:EclipseLink 2.1.1 / Problem with @ManyToOne(fetch = FetchType.LAZY)
Next Topic:Secondary table with join on constant value
Goto Forum:
  


Current Time: Fri Sep 19 22:11:04 GMT 2014

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

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