• Post Reply Bookmark Topic Watch Topic
  • New Topic

@SqlResultSetMapping

 
Lukas Hnatuk
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,
I am trying to do some NatveQueries, but I am stuck with @SqlResultSetMapping configuration.

I have those classes:


My question is, how to write propper @SqlResultSetMapping for class LocalUser. My test SQL statement is


and I would like to get one Entitny Local user, with username user, password passwd and List of roles, where is admin with id 1.

I figgured as far something like this:


but it gives me two objects, instead of one.

Can anybody help me please?

Thanks
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't define this with a ResultSetMapping, other than getting the two objects back.

If you are using EclipseLink, you could use a normal native query for the class and set the join-fetch hint. It should then build the objects that you want.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!