How can I force Hibernate to update an entity instance even if the entity is not dirty? I'm using Hibernate 3.3.2 GA, Hibernate Annotations and Hibernate EntityManager btw. I really want Hibernate to execute the generic UPDATE statement even if no property on the entity has changed.
I need this because some event listeners need to get invoked to do some additional work when the application runs for the first time.
Thanks!
ok - found it myself. This does the trick:
Session session = (Session)entityManager.getDelegate();
session.evict(entity);
session.update(entity);
For transients, you can check
if(session.contains(entity)) {
session.evict(entity);
}
session.update(entity);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With