Reputation: 2211
I am using Guice, Guice Persist, Hibernate and Jersey. All my resource methods are annotated with @Transactional except for the methods that are annotated with @GET. Is this the correct way configure the transaction-per-request scope?
Upvotes: 1
Views: 885
Reputation: 473
There is no "correct" way; it depends on what you are trying to achieve. There is a few separate issues involved in answering your question, as discussed below.
In summary, your data access pattern is fine, as long as your controllers are request-scoped. However, your "GET" functions should be transactional if many queries will be involved in creating the object graph.
Upvotes: 4