Announcement Announcement Module
Collapse
No announcement yet.
[Q]: Architure Advice Needed Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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:

    Code:
    	<bean 	id="baseTransactionProxy" abstract="true" lazy-init="default"  
    			dependency-check="default" autowire="default"
    			class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    		<property name="transactionManager" ref="transactionManager"/>
    		
    		<property name="transactionAttributes">
    			<props>
    				<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>				
    			</props>	
    		</property>
    		
    		<property name="postInterceptors">
    			<list>
    				<ref bean="theLogger"/>
    			</list>
    		</property>
    	</bean>
    
    	<bean id="transactionManager"
    		class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    		<property name="sessionFactory" ref="sessionFactory" />
    	</bean>
    
    	<bean id="sessionFactory"
    		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    		<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">
    			<value>classpath*:**/*.hbm.xml</value>
    	    </property>
    
    		<!-- 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">
    			<value>classpath*:**/services.jar</value>
    	    </property>
    
    		<property name="hibernateProperties">
    			<props>
    				<prop key="hibernate.dialect">
    					org.hibernate.dialect.Oracle9Dialect
    				</prop>
    				<prop key="hibernate.show_sql">false</prop>
    				<prop key="hibernate.generate_statistics">false</prop>
    			</props>
    		</property>
    		
    		<property name="eventListeners">
    			<map>
    				<entry key="merge">
    					<bean
    						class="org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener" />
    				</entry>
    			</map>
    		</property>
    	</bean>
    
    	<bean id="dataSource"
    		class="org.springframework.jndi.JndiObjectFactoryBean">
    		<property name="jndiName"
    			value="jdbc/ScaGlobalDataSource" />	
    	</bean>
    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,
    Ken
Working...
X