the session is injected via spring, so i dont need to care about that. also the transaction is started through spring. the transaction simply spoken starts on function-call and ends when leaving it. all i need to do is marking a function with the annotation
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
and some configuration in the spring context
hmm merge really seams to do the job, thx!
but is there any way to tell hibernate only to update properties that are not-null?
to make an example e.g. my domain-object is:
Code:
class EmailAddress{
String costumernumber;
String address;
String usage;
}
my database allready contains a record for the given costumernumber - which is unique. in this case the address changed (the data is red from another database). the usage is incremented each time a special application reads the email-address in my database.
the point is: my datasource does not contain any information about that usage-field, so eventually it would be null each time i get the updated EmailAddress from my it.
so an EmailAddress in my List<EmailAddress> now would contain the new address and the costumernumber, but the usage field is null since it would not contain any new data.. now i dont want hibernate to update this field if its null.
is that possible?