Quantcast
Channel: Java Programming Forum - Learn Java Programming - Hibernate
Viewing all articles
Browse latest Browse all 76

DetatchedCriteria without on clause

$
0
0
Hi All!

I'm relatively new to Hibernate. I have to use the 3.2 version and i need to use DetachedCriteria and obtain the following query:

select this_.ID as ID0_1_, this_.SNDG as SNDG0_1_, this_.NDG as NDG0_1_, this_.T_GWR_PARTNER_ID as T4_0_1_, table2x1_.ID as ID1_0_, table2x1_.T_GWR_PROPOSAL_ID as T2_1_0_, table2x1_.GROUP_SNDG as GROUP3_1_0_, table2x1_.GROUP_NAME as GROUP4_1_0_ from t_gwr_proposals this_ inner join t_gwr_proposal_ratings table2x1_ where table2x1_.T_GWR_PROPOSAL_ID=this_.ID

but I obtain the follwing

select this_.ID as ID0_1_, this_.SNDG as SNDG0_1_, this_.NDG as NDG0_1_, this_.T_GWR_PARTNER_ID as T4_0_1_, table2x1_.ID as ID1_0_, table2x1_.T_GWR_PROPOSAL_ID as T2_1_0_, table2x1_.GROUP_SNDG as GROUP3_1_0_, table2x1_.GROUP_NAME as GROUP4_1_0_ from t_gwr_proposals this_ inner join t_gwr_proposal_ratings table2x1_ on this_.ID=table2x1_.ID where table2x1_.T_GWR_PROPOSAL_ID=this_.ID

using this code:

Criteria c = session.createCriteria(T_gwr_proposals.class, "Table1");
c.createAlias("Table1.T_gwr_proposal_ratings", "Table2"); // inner join by default
c.add(Restrictions.eqProperty("Table2.t_gwr_propos al_id", "Table1.proposalsId"));
return c.list();

Can anyone help me, please?

Thank you very much,

Tommaso A.

Viewing all articles
Browse latest Browse all 76

Trending Articles