With the following code
Code:
Criteria dc = session.createCriteria( TableA.class , "myTable1" );
dc.createAlias( "tableBSet", "myTable2" );
dc.add( Restrictions.eqProperty( "myTable1.columnOne", "myTable2.columnOne" ) );
dc.add( Restrictions.eqProperty( "myTable1.columnTwo", "myTable2.colunTwo" ) );
dc.add( Restrictions.eq( "myTable1.columnOne", new Long( 1 ) ) );
dc.add( Restrictions.eq( "myTable2.columnThree", new Boolean(false) ) );
I have the following SQL logged in console
Code:
select
table1.ALL_COLUMNS, table2,ALL_COLUMNS
from
TABLE_A table1
inner join
TABLE_B table2
on table1.COL_1=table2.COL_1
and table1.COL_2=table2.COL_2
where
table1.COL_1 = table2.COL_1
and table1.COL_2 = table2.COL_2
and table1.COL_1=?
and table2.COL_3=?
and I have bi-directional relation defined on the mapping files. Dont know why you have a different SQL with the same code.
If you want distinct results, try setting
Criteria.setResultTransformer( Criteria.DISTINCT_ROOT_ENTITY );