Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Defining own way of mapping SQL result to Object

Provided the native SQL returns all of the required data, you can set the
joinAttributes on the ReadAllQuery (or use hint in JPA) to enable joining
with a native SQL query.

You could also use a normal JPQL or Expression query with the joining and
have EclipseLink generate the SQL.



agatone wrote:
> 
> Hi,
> 
> I'm sorry maybe this is a simple thing to solve, but I can't find a
> solution to it - or don't know exactly what too look for.
> 
> I've got a SQL result set (from join of two tables order and suborder)
> 
> order_id | order_name | suborder_id | suborder_name |
> -----------------------------------------------------
> 1          | ord1           | 1              | subord1           |
> -----------------------------------------------------
> 1          | ord1           | 2              | subord2           |
> -----------------------------------------------------
> 1          | ord1           | 3              | subord3           |
> -----------------------------------------------------
> 2          | ord2           | 4              | subord4           |
> -----------------------------------------------------
> 2          | ord2           | 5              | subord5           |
> -----------------------------------------------------
> 
> When i map (by session.readAllObjects) that to my class Order (which has
> @OneToMany of Suborder defined in it) I get collection of 5 objects but
> I'd like to get collection of 2 Order objects of which each contains
> collection of it's suborders.
> 
> Is that possible to do automatically or I have to loop through all objects
> and regroup them myself?
> 
> Thank you.
> 
> P.S.: sorry for resend to the list but i had to subscribe to mailing list
> 


-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://old.nabble.com/Defining-own-way-of-mapping-SQL-result-to-Object-tp26160055p26163590.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top