How to handle transactions with Spring Data JPA? -
i start creating new application , wanted feedback on approach plan on using. using spring , spring data jpa.
can controllers call domain services , repositories or should controller make calls application , infrastructure services?
if "ok" call domain services , repositories controller , domain service operation needs transaction, can/should put @transactional annotation on domain service method? or should have application service wraps call (not sure approach because end bunch of pass through methods)?
if not "ok" call domain services , repositories controller need create application services wrap possible domain service calls(like said in 2 lot of pass through methods)?
the best solution can come following:
repositories have @transactional annotation propagation required when writing database , propagation set readonly=true , propagation set supports when reading database.
application , domain services add @transactional annotation needed
if controller ever needs make make direct call repository domain service or application service can. no pass throughs.
i not clear question. domain services doing? knew application services , domain repositories well.
in spring , there 2 layers service , data access layer. service layer can used @service (in design application services) not used @transactional tag.
data access layer used @repository tag , @transactional tag, because layer directly connected , make operation database. so, know 's function of domain service. not clear that.
thanks buddy.
Comments
Post a Comment