[nanocontainer-scm] [jira] Commented: (NANO-97) nano-persistence
jira-yCVjj/[email protected] Thu, 7 Oct 2004 14:48:53 -0400 (EDT)
| Newsgroups | gmane.comp.java.nanocontainer.cvs |
|---|---|
| Message-ID | <[email protected]> |
The following comment has been added to this issue:
Author: Philipp Meier
Created: Thu, 7 Oct 2004 2:48 PM
Body:
Konstantin, yes the application uses a ThreadLocal to access the session. This enables a rather uninstrusive programming model. The AOP interceptor associates the session with the ThradLocal and commits the TX afterwards. The advantage is that session and tx context is propagated transparently from instance to instance:
public class FooManager {
private LogManager logManager;
public FooManager(LogManager logManager) { ... }
public void createFoo(Foo foo) {
ThreadLocalSessionProvider.getSession().save(foo);
logManager.log("Created foo: " + foo);
}
}
public class LogManager {
public void log(String msg) {
LogBean log = new Log(msg);
ThreadLocalSessionProvider.getSession().save(log);
}
}
If in the aop implementation of your choice FooManager.createFoo and LogManager.log are wrapped with a HibernateInterceptor the automatically share TX and Session. If either method fails the TX is beeing rolled back.
Further implementations of HibernateInterceptor will support different TX joining methods. Consider the EJB spec for details.
A different approach would be to re-instantiate the Manager / DAO objects on every use and pass the current session / tx in the constructor. Konstantin, IMHO you have a web / xwork background where is easy to provide a new instance for each request, where this is not possible or feasable the described methode is an alternative.
---------------------------------------------------------------------
View this comment:
http://jira.codehaus.org/browse/NANO-97?page=comments#action_25081
---------------------------------------------------------------------
View the issue:
http://jira.codehaus.org/browse/NANO-97
Here is an overview of the issue:
---------------------------------------------------------------------
Key: NANO-97
Summary: nano-persistence
Type: New Feature
Status: Unassigned
Priority: Major
Original Estimate: Unknown
Time Spent: Unknown
Remaining: Unknown
Project: NanoContainer
Assignee:
Reporter: Philipp Meier
Created: Wed, 1 Sep 2004 1:14 PM
Updated: Thu, 7 Oct 2004 2:48 PM
Description:
Stephen Molitor intially suggestest this module on the pico-dev-list. I file this issue to have a place to attach my contribution of code.
---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira