nestorjb wrote:
Hi, Thanks for the quick reply emmanuel
The thing is that my data access objects will receive a new instatiated object, not a session loaded object and I have to update the database with this object. I know that there is a saveOrUpdateCopy method but I'm not sure if I can use this for what I need.
I do the same thing with my DAO layer. I get the initial object and pass it off to struts to display to forms. Once the user updates the object on screen, the changes are put together to construct a new instance of the object. I pass the new instance into the DAO and use saveOrUpdate() to do an update based on the primary key value. This is controlled by the following attribute in the mapping.
Code:
<id
name="userGroupId"
column="USERGROUPID"
type="java.lang.Long"
unsaved-value="null"
>
<generator class="sequence">
<param name="userGroupId">SEQ_USERGROUPID</param>
</generator>
</id>
Note, if the primaryKey is 0 instead of null, it will try to do an insert instead of an update.
Hope that helps.