-->
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: Connect between the two criteria if there is no relations?
PostPosted: Mon Sep 22, 2008 5:45 am 
Newbie

Joined: Sun Sep 17, 2006 7:55 pm
Posts: 2
Dear All!!!

I have two tables, these tables are NOT connected in Hibernate (no any relations in Hibernate mapping).
I can easily write HQL statement for select, but how do I write query using classic Hibernate Criteria API?

Here is an example :
Two Tables :
Table1 (Column1, Column2)
Table2 (Column1, Column2)

Two mappings:

Code:
<hibernate-mapping default-cascade="all,delete-orphan" >
   <class lazy="true" name="Tbl1"
      table="Table1" dynamic-update="true" dynamic-insert="true" rowid="rowid">
      <id name="column1"  column="column1"></id>
      <property name="column2" column="column2"></property>
   </class>
</hibernate-mapping>


Code:
<hibernate-mapping default-cascade="all,delete-orphan" >
   <class lazy="true" name="Tbl2"
      table="Table2" dynamic-update="true" dynamic-insert="true" rowid="rowid">
      <id name="column1"  column="column1"></id>
      <property name="column2" column="column2"></property>
   </class>
</hibernate-mapping>


I would like to write the next statement in regular SQL:
Select Table1.* from table1, table2 where table1.column2=table2.column2


I know how to write it using HQL.
But I would like to write it using Criteria API:

Criteria c1 = Session.createCriteria(Tbl1.class);
Criteria c2 = Session.createCriteria(Tbl2.class); ...

How do I connect between the two criteria if there is no relation between the two mappings? Thank you in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 24, 2008 1:10 am 
Newbie

Joined: Sun Sep 17, 2006 7:55 pm
Posts: 2
up


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.