java - Does TransactionAttributeType.NOT_SUPPORTED make sense for retrieving entities? -


does having transactionattributetype.not_supported on every db lookup method makes sense? don't see point in having entity attached if it's not going execute update.

@transactionattribute(transactionattributetype.not_supported) pubic list<anentity> getlistentities(){     typedquery<anentity> query = em.createnamedquery("anentity.myquery",anentity.class);     return query.getresultlist(); } 

does still end in cache?

the time seems useful use required transcation propagation when update required:

 @transactionattribute(transactionattributetype.required)  public void editpersonname(integer id, string newname){       anentity anentity= em.find(anentity.class, id);       anentity.setname(newname);  } 

other don't see point.

no, doesn't make sense use not_supported transaction propagation read-only queries, makes lot of sense use default required transaction propagation. need transaction reading data too. database uses transaction, no matter if specify or not.

using explicit transaction allows group several statements in single transaction, and, if using hibernate, might avoid aggressive connection release overhead.

just because jpa allows executed read queries without transaction, doesn't mean have way.

the not_supported mode useful when want execute service method outside of current transaction scope , that's useful methods don't need transaction @ (e.g sending email) avoid overhead of starting/ending transaction context.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -