Hi,
I have been using the binding direct to domain object pattern for a while. I
am using hibernate and the Session per Request pattern. I am also using
Managed Session Context introduced in Hibernate 3.x.
Yesterday I discovered something very disturbing. In one of my action beans
I have something like the following:
@After(stages=LifecycleStage.BindingAndValidation)
public void afterBind() {
states = lookupService.getStateCodes(myDomainObject.getCountry());
}
The main point is that there is a service call, which is managed by Spring's
Transaction Manager. The Transaction Manager will open and commit a
transaction. but since it is using the same Session that I obtained my
domain object from, the domain object (along with the bindings) got
committed into the database as well. It happened before the event handler,
and it is unintended.
I think the problem lies with Hibernate's Managed Session Context (which
maintains a single session and transaction per context) and the Transaction
Manager automatic propagation of transactions.
There is an article about this pattern in stripes website:
http://www.stripesframework.org/display/stripes/Binding+Into+Domain+Models,
but the example is a two tier architecture.
I am beginning to think that binding to domain object maybe is not a good
idea for 3 tiers architecture. There is too many ways to go wrong.
Can someone share your experience on this?
Many thanks in advance.
Regards,
Yee
------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users