开发者

Java RMI and Hibernate: Managing sessions and transactions

开发者 https://www.devze.com 2023-01-29 15:05 出处:网络
In my ASP.NET projects I follow a transaction-per-request pattern for dealing with NHibernate using a custom HttpModule. I\'ve recently been working on a Java client and server app using RMI and am lo

In my ASP.NET projects I follow a transaction-per-request pattern for dealing with NHibernate using a custom HttpModule. I've recently been working on a Java client and server app using RMI and am looking for a nice way to handle sessions and transactions, currently this is done manually.

Is there anyway to intercept the RMI request so I can open/close the session where appropriate or should I be looking into using something like Spring? I'm new to Jav开发者_如何学Pythona so please be gentle :)

Thanks


Spring would be a good way to manage this. It uses aspect oriented programming techniques to manage transactions. Usually they're added to POJO service interfaces. You can choose to expose your POJO services using RMI, but that's just one choice among many.

I wouldn't associate a transaction with a session unless it was very long running.

Another approach would be to embrace EJB 3.0. It took a lot from Spring: dependency injection, aspect oriented programming. It also has a declarative transaction model.

0

精彩评论

暂无评论...
验证码 换一张
取 消