-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate query different result in SQL studio (LEFT JOIN)
PostPosted: Fri Nov 05, 2004 9:19 am 
Newbie

Joined: Fri Nov 05, 2004 8:16 am
Posts: 1
Hibernate version: 2.1.3

Name and version of the database you are using: SAP DB

The generated SQL (show_sql=true):

select patient0_.id as x0_0_, polissen3_.verzekeringsvorm as x1_0_, episoden2_.icpc_code as x2_0_, episoden2_.begindatum as x3_0_, uitslagen4_.datum as x4_0_, bepaling5_.memo as x5_0_, antwoord7_.antwoord as x6_0_
from patient patient0_,
medischdossier medischdos1_, episode episoden2_, polis polissen3_, uitslag uitslagen4_, bepaling bepaling5_, uitslagantwoord antwoorden6_, antwoord antwoord7_
where patient0_.medischdossier_id=medischdos1_.id
and medischdos1_.id=episoden2_.dossier_id
and patient0_.id=polissen3_.patient_id
and medischdos1_.id=uitslagen4_.medischdossier_id(+)
and uitslagen4_.bepaling_id=bepaling5_.id(+)
and uitslagen4_.id=antwoorden6_.uitslag_id(+)
and antwoorden6_.antwoord_id=antwoord7_.id(+)
and ((patient0_.praktijkmedewerker_id IN(? , ? , ? , ?))
AND(patient0_.categorie='eigen-intern' )
AND(episoden2_.icpc_code IN(? , ? , ?))
AND(((polissen3_.uitschrijfdatum is null )
AND(polissen3_.inschrijfdatum<? ))OR((polissen3_.uitschrijfdatum>? )
AND(polissen3_.inschrijfdatum<? ))))


The result in the Java application gives me a list with 12 results. When I copy paste this code in SQl studio then there are only 7 results. 7 results is the correct number. The query below is the String which I send to hibernate. The main thing that goes wrong is somewhere in the LEFT JOIN's. But I can't discover what.
The 12 results all have the same value in antwoord.antwoord. Why isn't antwoord.antwoord null when nothing was found in uitslag.

I hope someone can help me fix this problem, else I will have to deal with serious performance problems.


[i]String queryString = "SELECT patient.id, polis.verzekeringsvorm, episode.icpcCode ,episode.begindatum, " +
" uitslag.datum, bepaling.memo, antwoord.antwoord"+
" FROM " + Patient.class.getName() + " AS patient" +
" INNER JOIN patient.medischdossier AS dossier" +
" INNER JOIN dossier.episoden AS episode" +
" INNER JOIN patient.polissen AS polis" +
" LEFT JOIN dossier.uitslagen AS uitslag" +
" LEFT JOIN uitslag.bepaling AS bepaling" +
" LEFT JOIN uitslag.antwoorden AS antwoord" +
" WHERE patient.praktijkmedewerker IN (:MEDEWERKERS)" +
" AND patient.categorie = '" + CoreConstants.ASP_PATIENT_CAT_EIGEN_INTERNAL +"'" +
" AND episode.icpcCode IN (:ICPCCODESDIABETES)" +
" AND ((polis.uitschrijfdatum is null AND polis.inschrijfdatum < :EINDDATUM)" +
" OR (polis.uitschrijfdatum > :EINDDATUM AND polis.inschrijfdatum < :EINDDATUM))";[i]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.