[Q]: Architure Advice Needed
We are having an issue with an application that we have. Originally, we set up our architecture using Spring + Struts2 + Hibernate.
We have implemented a Open View In Session approach to open a Hibernate Session when a request is first made and to then close it on the way out. This allows us to access any lazy initialized properties in our hibernate domain objects from our JSPs.
We have established our BOs in spring to all be a manifestation of our base BO which implements our transaction demarcation and handling. The configuration is as follows:
Our problem is that we have thought that we were implementing an architecture that would not require DTO and that we would be able to reference our Hibernate domain objects directly from within our web layer. However what we are finding is that when we update these objects, Hibernate does not seem to care if we specifically call a save or update on these domain objects. When any transaction or session is committed or flushed, any object thought to be dirty appears to be saved to the database. This is causing serious issues for us as objects that have yet to be validated or that we do not want saved to the database are being saved regardless.
<bean id="baseTransactionProxy" abstract="true" lazy-init="default"
<property name="transactionManager" ref="transactionManager"/>
<!-- The setUser method in the BO's does not perform any database activity. -->
<property name="sessionFactory" ref="sessionFactory" />
<property name="dataSource" ref="dataSource" />
<!-- This config is for unit tests as the jar will not exist yet. -->
<!-- It does not work at runtime since the files will be located in a jar and hibernate will not pick them up. -->
<!-- This config does not work for unit tests as the jar will not exist yet. -->
<!-- It does work at runtime since the files will be located in a jar. -->
We have what we believed to be a common setup and are expecting and doing nothing out of the ordinary. Sure we have something setup or configured wrong with our session or transactions. Any help or advice would be GREATLY appreciated!
Thanks in advance,