[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-7303) inner join problem when use constructor in JPQL

deng hui (JIRA) noreply at atlassian.com
Sat May 5 10:36:09 EDT 2012


    [ https://hibernate.onjira.com/browse/HHH-7303?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=46543#comment-46543 ] 

deng hui commented on HHH-7303:
-------------------------------

sorry, the right join should be left join.
the issue is same. 


> inner join problem when use constructor in JPQL
> -----------------------------------------------
>
>                 Key: HHH-7303
>                 URL: https://hibernate.onjira.com/browse/HHH-7303
>             Project: Hibernate ORM
>          Issue Type: Bug
>          Components: entity-manager
>    Affects Versions: 4.1.0
>         Environment: Spring 3.1.1
>            Reporter: deng hui
>
> I have 2 domain classes: 
> 'Process' and 'Account' they are keeping Many-To-One relationship which means:
> Process may belongs to one Account or not belongs to any Account, 
> and one Account can own multi-Process.
> a query in Spring Framework like
> {code}
> public interface ProcessRepository extends CrudRepository<Process, Long> {
> 	@Query("select distinct new Process(p.id, p.name,p.diversity,p.version,p.account,p.description) from Process p right join p.account where p.name like ?1 and p.state.id=1")
> 	List<Process> findProcessByName(String name);
> }
> {code}
> when app is running i got:
> {code}
> Hibernate: select distinct process0_.id as col_0_0_, process0_.name as col_1_0_, process0_.diversity as col_2_0_, process0_.version as col_3_0_, process0_.account_id as col_4_0_, process0_.description as col_5_0_ from Process process0_ right outer join Account account1_ on process0_.account_id=account1_.id inner join Account account2_ on process0_.account_id=account2_.id where (process0_.name like ?) and process0_.state_id=1
> {code}
> no record retrieved. 
> if I change to 
> {code}
> public interface ProcessRepository extends CrudRepository<Process, Long> {
> 	@Query("select distinct new Process(p.id, p.name,p.diversity,p.version,p.account,p.description) from Process p where p.name like ?1 and p.state.id=1")
> 	List<Process> findProcessByName(String name);
> }
> {code}
> then I got:
> {code}
> Hibernate: select distinct process0_.id as col_0_0_, process0_.name as col_1_0_, process0_.diversity as col_2_0_, process0_.version as col_3_0_, process0_.account_id as col_4_0_, process0_.description as col_5_0_ from Process process0_ inner join Account account2_ on process0_.account_id=account2_.id where (process0_.name like ?) and process0_.state_id=1
> {code}
> this(inner join) is also not I want since account may be null in process object. 
> is this a bug?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list