Aaron Porter <aa...@...> writes: > > > Hi Yee, > I don't know if you're using JPA but if you are you might want to > consider using Stripersist. The problem you're having sounds like it is > due to Stripes binding into your entities before a transaction has > started. Stripersist avoids that problem by starting a transaction > before doing anything else and requires you to explicitly commit > transactions. Any open transactions at the end of a request are rolled > back automatically. > Aaron
Stripersist is not 3 tier architecture. But in the light of what I discovered, it seems to be impossible to do proper 3 tier with hibernate. If any hibernate object is passed out of the service tier there is no way to guarantee that the UI tier did not change them inadvertently. Even the innocent lookup table objects can ended up being modified and got persisted! The only way around this is to not allow any hibernate object to leak out of the service tier by using DTOs, but this is completely against Hibernate philosophy! I think this is a very serious matter. It seems to me that the very philosophy of Hibernate is making it uniquely unsuited for 3 tier architecture. I wondered why I have not came across any discussions regarding this all these years. I will investigate whether I can tweak the FLUSH_MODE to make hibernate behave properly in 3 tier architecture. But stripersist is looking very attractive to me now. > CN Yee wrote: > > CN Yee <yeechut <at> ...> writes: > > > > I just confirmed that the problem lies with hibernate. > > The following code will persist everything in the session to database. > > Session s = sessionFactory.getCurrentSession(); > Transaction tx = s.beginTransaction(); > tx.commit(); > > That is very nasty. Anybody has any experience to share regarding this? > > Regards, > Yee > > > > I found the following; > > "With hibernate it is important to understand what exactly is going on under >the > covers. At every commit boundary it will attempt to flush all changes to >objects > in the current session regardless of whether or not the changes where made in > the current transaction or any transaction at all for that matter." > > http://stackoverflow.com/questions/244381/hibernate-transaction-problem > > I think this pretty confirms that binding to domain model pattern is indeed >not > tenable for 3 tier architecture. > > Regards, > Yee > ------------------------------------------------------------------------------ _______________________________________________ Stripes-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/stripes-users
