-->
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: HQL Left Join
PostPosted: Mon Feb 02, 2009 10:03 pm 
Newbie

Joined: Tue Jun 10, 2008 4:40 am
Posts: 13
Hello,
Please fix my hql, i try to use hql left join

etc table
AskCommitment (master table)

idAsk Question
1 Ask1
2 Ask2
3 Ask3


Rwycommitment
idAsk Answer
1 T
2 Y


i have use hql like this
Code:
from Rwycommitment as r left join r.askCommitment as ask
where ask.idAsk = r.askCommitment

but result like
idAsk question answer
1 Ask1 T
2 Ask2 Y

i want result like this

idAsk question answer
1 Ask1 T
2 Ask2 Y
3 Ask3 null


this my code
Code:
@Entity
@Table(name="t_askcommitment")
public class AskCommitment implements java.io.Serializable{

@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="ID_ASK")
private int idAsk;

@Column(name="QUESTION", nullable=true, unique=false, length=400)
private String question;



Code:
@Entity
@Table(name="t_rwycommitment")
public class Rwycommitment implements java.io.Serializable{
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="ID_COM")
private long idCom;


@Column(name="ANSWER", nullable=true, unique=false, length=3)
private String answer;


@ManyToOne
@JoinColumn(name="ID_ASK")
private AskCommitment askCommitment;


thanks[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 03, 2009 1:54 am 
Newbie

Joined: Tue Jun 10, 2008 4:40 am
Posts: 13
Please help me


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 03, 2009 3:57 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
You should remove the "where" condition in your query, The following should work.

Code:
from Rwycommitment as r left join r.askCommitment as ask


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.