I have object called Property. in this multiple concerns associated.
<class name="Property"
table="T_PROPERTY">
<id name="propertyId" type="integer" column="PRTY_ID">
<generator class="native" />
</id>
<property name="propertyName" column="PRTY_NAME" type="string"/>
<many-to-one name="propertyType" class="com.mmm.ehspreg2.entity.property.PropertyType" column="PRTY_TYP_ID" />
<property name="active" column="ACTV" type="boolean"/>
<set name="propertyConcern">
<key column="PRTY_ID"/>
<one-to-many class="PropertyConcern"/>
</set>
</class>
<class name="PropertyConcern"
table="T_CONCERN">
<id name="prtyCrnId" type="integer" column="PRTY_CRN_ID">
<generator class="native" />
</id>
<many-to-one name="concern"
class="com.mmm.ehspreg2.entity.property.Concern" column="CRN_ID" />
<many-to-one name="property"
class="com.mmm.ehspreg2.entity.property.Property" column="PRTY_ID" />
</class>
So i need List of unique property object,below is my code
Criteria criteria = getPersManager().getCurrentSession()
.createCriteria(Property.class).createAlias("propertyType",
"type").createCriteria("propertyConcern",
"propertyConcern", CriteriaSpecification.LEFT_JOIN)
.createCriteria("propertyConcern.concern",
CriteriaSpecification.LEFT_JOIN).setFetchMode("type",
FetchMode.JOIN).setFetchMode("propertyConcern",
FetchMode.JOIN).setFetchMode("propertyConcern.concern",
FetchMode.JOIN).setResultTransformer(
CriteriaSpecification.ROOT_ENTITY);
List of property, if i traverse throth property i should get the other objects.I am able to get the other objects, but Property object is getting duplicated.How should i avoid it? Please help me.