We are using Hibernate version 2.1.2.
We have an object that has a primary key composed of 2 fields and we are using a composite id object. We need to be able to:
1. Retrieve an object
2. Allow the user to update the object, including the values of the fields that comprise the primary key.
3. Save the updated object (and composite id object)
The question I have is this:
What is the best approach to updating the object and the composite id object? The approach that we are planning to take is outlined below.
1) Change property setters for the composite key properties so that they remember their old values.
2) Process the change by:
- Creating a session
- Finding an instance of the object by its key (based on old key values)
- Updating that instance with the new key values from the composite id object
- committing
Does anyone has any suggestions for a better/cleaner way?
Thank you,
Julie
|