Monday, September 29, 2014

Can we create a hibernate file with out id field?

Answer is NO.

Here is why?
Hibernate identifies Objects (in first and 2nd level cache) using the ID of the object, so an object without an ID cannot be represented in hibernate.

Solution:
You need create a composite key combination . But finally you need to have any one of id combination. :-)

  <class name="com.cscinfo.nameprotect.db.np.dao.VaObBuildQueueView" table="VA_OB_BUILD_QUEUE_VIEW" schema="NP">
    
    <composite-id>
<key-property name="fileId" column="FILE_ID"  />
<key-property name="fileDataId" column="FILE_DATA_ID"  />
<key-property name="vaBuildRequestId" column="BUILD_REQUEST_ID"  />
</composite-id>

No comments: