Is it possible to use the session.load(class, id) with a composite key?
I have several classes that I have implemented using composite keys such as the following class
public class ASControlSection {
private ASControlSectionCompositeKey ascskey = null;
private String asControlSectionDesc =null;
}
public class ASControlSectionCompositeKey implements Serializable{
private String asStationCode =null;
private String asAllocationCode =null;
private String asControlSectionCode =null;
}
The mapping xml is
hibernate-mapping>
<class name="uk.co.customerinteraction.dao.ASControlSection" table="LTRAPF.TKDYREP">
<composite-id name="ascskey" class="uk.co.customerinteraction.dao.ASControlSectionCompositeKey">
<key-property name="asAllocationCode" column="DYSEC2"/>
<key-property name="asControlSectionCode" column="DYSGC2"/>
<key-property name="asStationCode" column="DYSCC2"/>
</composite-id>
<property name="asControlSectionDesc" column="DYK3NA"/>
</class>
</hibernate-mapping>
At the moment I am using a hibernate Query to retreive the object, but was wondering if I would be better using the session.load(class, id).
If it is possible which is more efficient, the query on the primary key or the session.load?
thanks in advance
|