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.