transactions - Java and Spring implement transactional function -
i'm using java 1.6 , spring 3.0.4, want realize java functionality
- calculate new data values
- update one-by-one existing values on database
if in of step there's error want rollback whole transaction , come previous state.
i realized pieces of code, want put them together. how can manage existing spring values working @entity
, @column
annotations?
thanks!
short answer: you're using spring, easiest use the transaction management, creating service represents transaction unit , annotate method @transactional
in practice, need configure platformtransactionmanager
in application. seem use jpa, jpatransationmanager
seems obvious choice. enable processing of @transactional
annotation, can either use @enabletransactionmanagement
or <tx:annotation-driven/>
namespace. both explained in javadoc of @enabletransactionmanagement
by default, runtime exception thrown annotated method manage transaction rollback. if code using checked exceptions, you'll have configure rollbackfor
attribute of annotation.
there more details , examples available in documentation
Comments
Post a Comment