-->
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.  [ 3 posts ] 
Author Message
 Post subject: Left outer join with Criteria
PostPosted: Thu Jun 15, 2017 3:04 pm 
Newbie

Joined: Thu Jun 15, 2017 2:50 pm
Posts: 2
Hello,

I have, to simplify 2 classes

Code:
@Entity
@Table(name="SEA")
public class Sea {

@Column(name="ID_OBJECT")
private long idObject;

@Column(name="TYPE")
private String type;

@Column(name="LIBELLE")
private String libelle;

and
@Entity
@Table(name="NRL")
public class Sea {

@Column(name="ID_NRL")
private long idNrl;

@Column(name="ETAT")
private String etat;

@Column(name="DT_EXP")
private Date expiration;


There is no mapping between the 2 classes. I work from a Hibernate Criteria request that already exists and that I would like to improve in order to make a left outer join. The request would be in SQL the following
Code:
select s.TYPE, s.LIBELLE, n.ETAT, n.DT_EXP from SEA s LEFT OUTER JOIN  NRL n on (s.TYPE='NRL' and  s.ID_OBJECT = n.ID_NRL);


How to implement this request with Hibernate Criteria ? Thank you in advance for your answers


Top
 Profile  
 
 Post subject: Re: left outer join with criteria
PostPosted: Thu Jun 15, 2017 3:34 pm 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Hibernate Criteria is deprecated, but Hibernate 5.1 HQL supports ad-hoc joins:

Code:
select s, n
from SEA s
LEFT JOIN  NRL n on
    (s.type='NRL' and  s.idObject= n.idNrl)


JPA Criteria only supports the ON clause for existing associations, not for ad-hoc joins.


Top
 Profile  
 
 Post subject: Re: Left outer join with Criteria
PostPosted: Sat Jun 17, 2017 9:15 am 
Newbie

Joined: Thu Jun 15, 2017 2:50 pm
Posts: 2
Thank you viad for your answer


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

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.