• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help With JPA query

 
Gil Carvalho
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • 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]
 
Paul Clapham
Sheriff
Posts: 21583
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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:


 
Jayesh A Lalwani
Rancher
Posts: 2762
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • 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: 79
  • Mark post as helpful
  • send pies
  • 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]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic