Announcement Announcement Module
No announcement yet.
[Q]: Architure Advice Needed Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • [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:

    	<bean 	id="baseTransactionProxy" abstract="true" lazy-init="default"  
    			dependency-check="default" autowire="default"
    		<property name="transactionManager" ref="transactionManager"/>
    		<property name="transactionAttributes">
    				<prop key="*">PROPAGATION_REQUIRED</prop>
    				<!-- The setUser method in the BO's does not perform any database activity. -->
    				<prop key="setUser">PROPAGATION_NOT_SUPPORTED</prop>				
    		<property name="postInterceptors">
    				<ref bean="theLogger"/>
    	<bean id="transactionManager"
    		<property name="sessionFactory" ref="sessionFactory" />
    	<bean id="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.  -->
    		<property name="mappingLocations">
    		<!-- 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.  -->
    	    <property name="mappingJarLocations">
    		<property name="hibernateProperties">
    				<prop key="hibernate.dialect">
    				<prop key="hibernate.show_sql">false</prop>
    				<prop key="hibernate.generate_statistics">false</prop>
    		<property name="eventListeners">
    				<entry key="merge">
    						class="" />
    	<bean id="dataSource"
    		<property name="jndiName"
    			value="jdbc/ScaGlobalDataSource" />	
    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.

    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,