You are currently browsing the tag archive for the ‘collection’ tag.

Suppose I have a many to one relation between Task and User, there also a one to one relation between User and UserRegistration

In Task there is a collection like bellow:

<many-to-one name="createBy" column="CRE_BY" not-null="true"/>

In User there is a collection like bellow:

<many-to-one name="userRegInfo" column="USER_REG_ID" not-null="true" cascade="all" unique="true" />

Now if I want to access information from TaskInfo may need to join UserInfo with TaskInfo and as a result may need to join UserRegInfo and UserInfo to get specific data.

This can be done following way:


DetachedCriteria dCriteria =DetachedCriteria.forClass(TaskInfo.class);
- - - - - - - - -  - - - - - - - - -  - - - - - - - - - dCriteria.setFetchMode("createBy",FetchMode.JOIN).

setFetchMode("createBy.userRegInfo", FetchMode.JOIN);
- - - - - - - - -  - - - - - - - - -  - - - - - - - - - - -

May 2024
S M T W T F S
 1234
567891011
12131415161718
19202122232425
262728293031  

RSS Hima’s Blog

  • An error has occurred; the feed is probably down. Try again later.