Thanks for the info.
I have decided to go for the DTO pattern for this problem.
But now I am facing another problem.
To summarise let's suppose I have two tables:
COMPLETED_REQ and
PENDING_REQ.
Both tables used as key the field
ID and in the mapping file, this id is defined like this (based on Oracle sequence):
Code:
<id
name="id"
type="long"
unsaved-value="0">
<column
name="REQUEST_NUMBER"
sql-type="NUMERIC(12)"/>
<generator class="sequence">
<param name="sequence">seq</param>
<param name="column">nextval</param>
</generator>
</id>
When I insert a record in
PENDING_REQ, the ID is automatically assigned from one value generated by the sequence. The ID was set to the
unsaved-value (0).
Now suppose that I want to migrate that request from
PENDING_REQ to
COMPLETED_REQ while preserving the ID value.
Is this possible ?
I have tried, but it seems that even when the ID value is not equal to the
unsaved-value (in this case the COMPLETED_REQ keeps the ID of PENDING_REQ record) Hibernate calls the sequence to set a new ID value to the ID field.
How can I prevent that ?
Do I have to consider database triggers or Hibernate Interceptors to solve this ?
Thanks,
Jekkil