-->
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: joining three tables with criteria
PostPosted: Thu Sep 24, 2009 1:53 pm 
Newbie

Joined: Thu Sep 24, 2009 10:48 am
Posts: 1
Hi,

I am new to hibernate and need help setup the following

select a.* from a, b, c
where a.1stId = b.1stId
and b.2ndId = c.2ndId
and c.somecolumn = 'BLA';

i tried setting up below

@Entity
@Table(name="a")
@SecondaryTable(name="b")
public class a {
@Column(table="b")
private long Id2;

@Id
@Column(name="1stId")
private long Id1;

private c ac;
}

@Entity
public class c {
@Id
@Column(name="2ndId")
private long 2ndId
@Column(name="somecolumn")
private String someColumn;
}

primary key for table b is 1stId

Criteria crit = sess.createCriteria(a.class);
crit.createCriteria("ac").add(Restrictions.like("somecolumn", strVal)));


I get below sql instead

select a.* from a, b, c
where a.1stId = b.1stId
and b.1stId = c.2ndId
and c.somecolumn = 'BLA';


Please help, Thanks


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.