• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help With JPA query

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I'm using this sql query and it works in oracle database, but when i use that query in hibernate the values of two columns are the same, and it shouldn't be




The problem is i have a table who is referenced twice (morada- address)



and hibernate retrieves me only the first for both fields

Check the image please

How can i reach my goal??



regards
address.jpg
[Thumbnail for address.jpg]
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This part of the SQL looks strange to me:



You have the same condition twice there. Same thing in the next part:


 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) are you sure RESERVA.COD_MORADA_DE and RESERVA.COD_MORADA_PARA don't have the same values?
2) Try to make a smaller query with only Reserva, and double join with Morada
 
Gil Carvalho
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Sorry for the late reply but the query in sql developer and netbeans service database query works too

Check both images, one from sql developer and the other from netbeans.
I think the problem is hibernate don't recognize the Object Morada twice

I put a breakpoint in debuger and receive the adress twice, so must be hibernate problem with that sintax.

And now i receive this message

failed to lazily initialize a collection of role: gmc.gestaxi.domain.Morada.reservasForCodMoradaPara, no session or session was closed

My mapping is for one to many



and many to one



So now i'm lost....

any help please?
querySql.jpg
[Thumbnail for querySql.jpg]
querySqlNetbeans.jpg
[Thumbnail for querySqlNetbeans.jpg]
class.jpg
[Thumbnail for class.jpg]
reply
    Bookmark Topic Watch Topic
  • New Topic