-->
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.  [ 2 posts ] 
Author Message
 Post subject: Qyery with in Query
PostPosted: Sat May 19, 2007 10:58 pm 
Newbie

Joined: Sat May 19, 2007 10:50 pm
Posts: 4
Hi,

I have tow tables
tabel1 and tabel2

Query
Code:
select t1.co1,t2.col1 where table1 t1,tabel2 t2 where t1.id = t2.id


The following statment needs to be executed.
I have gone through the number of Hybernate tutorials but nothing is providing me with correct answer.

I dont want to use HQL for this simple query.

Can you let me know how can we execute this using hibernate.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 21, 2007 3:41 am 
Senior
Senior

Joined: Thu May 17, 2007 2:31 am
Posts: 194
Location: Sri Lanka
Hi

Try this.

You must have a property in Table1 class which related to Table2

extract of mapping file

<hibernate-mapping
>
<class
name="lk.wts.test.Table1"
table="Table1"
>

<!-- more -->
<many-to-one
name="table"
class="lk.wts.test.Table2"
cascade="none"
update="false"
insert="false"
lazy="false"
column="id"
/>

</hibernate-mapping>

If it is ok then try this

Criteria crit = sess.createCriteria(Table1.class, "t1")
.add(Restrictions.eqProperty("t1.id","t2.id"))
.createAlias("t1.table", "t2") ;


Amila

(Don't forget to rate)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.