• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Write Left Outer Join

 
dinesh thalis
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Below show my query, In here main table is "Account" , Joining table is "Customer". How can I write left outer join.



Account Entity




Customer Entity



Please How can I resolve it.
Thank You.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well there are two issues. 1) you have a projection query. which means you get an Object[] back or a List<Object[]> depending on the number of rows.

2) In your From clause you use the JOIN clause. so

FROM Customer c JOIN c.address a

To join a Customer with an Address. By default it will use a Left Outer Join.

Mark
 
dinesh thalis
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for reply, so I want to create outer join but that table(secondary) haven't relation with main table, In that case how can I create it.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you guys have a standard where you have to put all those annotations in your class, because for all those properties of your class that are the same name as the corresponding database field name doesn't need any Annotation. The smart defaults are all set to match what you have as those Annotations.

So you don't have an assocation mapping between those two class, but still want a left outer join. I would try two things

First, try just adding a "(+)" on the optional side, just like you would in SQL.

If that doesn't work, use SQL instead and use the "(+)" on the optional side.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic