I am having a mapping table called mapping_user_account, which is having a primary key as pk_user_account_id, fk_user_id, fk_account_id. and i have made hibernate-mapping file for this table as
Code:
<hibernate-mapping>
<id name="pkUserAccountId" type="int">
<column name="pk_user_account_id"/>
<generator class="assigned"/>
</id>
<many-to-one class="model.Account" fetch="select" name="luAccount">
<column name="fk_account_id" not-null="true"/>
</many-to-one>
<many-to-one class="model.User" fetch="select" name="luUser">
<column name="fk_user_id" not-null="true"/>
</many-to-one>
</hibernate-mapping>
and Model is look like
Code:
class MapUserAccount{
private int pkUserAccountId;
private Account luAccount;
private User luUser;
// getter setter
}
now I am trying to fetch User Object by using DetachedCriteria, but i am confuse that how should i Use that for scenario like:
I want to fetch the User, where fk_user_id =1 and fk_account_id=1 from mapping_user_account table.
I am using
user table to store the user data, and
account table for storing account information.
and this user_id belongs to
user table as pk_user_id, and account_id belongs to
account tabe as pk_account_id
Let me know if you guys want more detail
Please help me out, as i am a new user of hibernate