Hibernate Compsite Key without new class
composite-key, hibernate
Solution
Create an instance of `OtherAccount` and set just those two fields. Hibernate doesn't care that the instance has more fields than it needs.
Problem
I have simple hibernate mapping ``` <class name="com.domain.OtherAccount" table="ACCOUNT"> <composite-id > <key-property name="acctype" column="acctype" type="java.lang.Character"></key-property> <key-property name="accnum" column="accnum" type="java.lang.Integer"></key-property> </composite-id> <property name="accholder"></property> </class> ``` I do not want to create separate class for Composite Key. So, acctype and accnum are part of OtherAccount class only. Class implements serializable interface and hashCode() and equals() methods. I am able to create new object and persist it using, session.save(). But how can I retrieve existing object ? In session.get() method how to specify composite key ? ``` In session.get(OtherAccount.class, HOW TO SPECIFY COMPOSITE KEY HERE ) ```