I know function calls to services should be in a transaction.
but what about caching aspect?
option A
"beanServiceTarget" - non proxied service
"beanServiceTransaction" - a transaction proxy for "beanServiceTarget"
"beanService" - a cache proxy for "beanServiceTransaction"
so call to "beanService.findItem(String id)" might not even hit the db and no transaction were ever started.
option B
"beanServiceTarget" - non proxied service
"beanServiceCache" - a cache proxy for "beanServiceTarget"
"beanService" - a transaction proxy "beanServiceCache"
so call to "beanService.findItem(String id)" might not even hit the db but a transaction might be started (i'm not sure about this).
or
Option C
"beanDao1Target" - a non-proxied dao
"beanDao2Target" - a non-proxied dao
"beanDao1" - a cache proxy for "beanDao1Target"
"beanDao2" - a cache proxy for "beanDao2Target"
"beanServiceTarget" - non proxied service, uses "beanDao1" and "beanDao2"
"beanService" - a transaction proxy "beanServiceCache"
so call to "beanService.findItem(String id)" might not even hit the db but a transaction might be started (i'm not sure about this). Furthermore, i'm not sure if the dao should be proxied.
so... any suggestions how i should use cache proxy and transaction proxy together? or is there a cowboy neal way that i haven't figured out yet..


Reply With Quote
. I guess this very much depends on how your application is structured. The Daos are performing the actual data access so it makes sense to proxy them for caching. Obviously as you pointed out you do create a transaction although you never hit the database. I would still personally want the transaction boundary at the service layer.
) that you still would want your transaction boundary on the service layer. Thus starting a transaction always (which comes in quite handy when using Hibernate 