Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

How to Write Left Outer Join

 
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.
 
ranger
Posts: 17346
11
Mac IntelliJ IDE 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
Posts: 17346
11
Mac IntelliJ IDE 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
 
Live a little! The night is young! And we have umbrellas in our drinks! This umbrella has a tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic