I have a method that does a bunch of things; amongst them doing a number of inserts and updates. It\'s declared thusly...
@Transactional(propagation = Propag
This works for me:
TransactionInterceptor.currentTransactionStatus().setRollbackOnly();
I have service methods annotated with @Transactional
. When the validation fails, and I already have an entity attached to the current unit of work, I use sessionFactory.getCurrentSession().evict(entity)
to make sure nothing is written to the database. That way I don't need to throw an exception.