[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2689) HQL Query using the relationary operator "or"
Jukka Aho (JIRA)
noreply at atlassian.com
Wed Oct 17 05:06:39 EDT 2007
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2689?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_28450 ]
Jukka Aho commented on HHH-2689:
--------------------------------
I had the same problem with a table with to foreign keys that were nullable (and one of them was always null). When I queried those associations independently, everything worked fine, but together the query always returned null. The problem disappeared when I used left joins for both foreign key associations.
If this is your problem, it will probably disappear if you use left join for both matriculaGraduaco and matriculaLABO
FROM RequerimentoVO r
LEFT JOIN r.matriculaGraduaco as mg
LEFT JOIN r.matriculaLABO as mg
WHERE mg.id = :codigo or ml.matricula = :codigo
> HQL Query using the relationary operator "or"
> ---------------------------------------------
>
> Key: HHH-2689
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2689
> Project: Hibernate3
> Issue Type: Bug
> Components: query-hql
> Affects Versions: 3.2.0.cr4
> Environment: ORACLE 9I
> HIBERNATE 3.2
> Reporter: Luiz Alberto
> Priority: Critical
>
> *************
> EXAMPLE TABLE "REQUERIMENTO" IN THE DATA BASE
> ROWID | ID(PK) | LABO(FK) | GRADUACAO(FK)
> ---------------------------------------------------------
> 1 | 110 | 5302332 | NULL
> 2 | 120 | NULL | 4002993
> 3 | 130 | NULL | 5321663
> 4 | 140 | 3698566 | NULL
> 5 | 150 | 5699636 | NULL
> *************
> Mapping
> RequerimentoVO
> .getMatriculaGraduacao() --> GraduacaoVO
> .getMatriculaLABO() --> LaboVO
> **************
> I use one query "HQL". Predicate "OR" is used of the following form.
> " FROM RequerimentoVO r "
> " where ( r.matriculaGraduacao.id = :codigo or r.matriculaLABO.matricula = :codigo ) "
> Which is the problem? It is bug of the Hibernate? Query returns "null"
> which and the problem? I am thankful
> ***************
> Exception when:
> " FROM RequerimentoVO r "
> " where r.matriculaGraduacao.id = :codigo "
>
> it returns a RequerimentoVO
>
> or in such a way
> " FROM RequerimentoVO r "
> " where r.matriculaLABO.matricula = :codigo = :codigo "
> it returns a RequerimentoVO
> which and the problem? I am thankful
> I am thankful !
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list