Hi
I am new to spring and hibernate. I have a question about how hibernate session is getting created. This is what I have in my web.xml
Few other configuration files...Code:<filter> <filter-name>hibernateFilter</filter-name> <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class> </filter>
Application-datasource.xml
Application-dao.xmlCode:<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="lobHandler"> <ref bean="oracleLobHandler"/> </property> <property name="mappingDirectoryLocations" value="classpath*:com/biogenidec/ttp/data/"/> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">${hibernate.dialect}</prop> <prop key="hibernate.cglib.use_reflection_optimizer">false</prop> <prop key="hibernate.show_sql">false</prop> <prop key="hibernate.hbm2ddl.auto">${hbm2ddl.auto}</prop> <prop key="hibernate.generate_statistics">true</prop> <prop key="hibernate.default_batch_fetch_size">0</prop> <prop key="hibernate.cache.use_structured_entries">true</prop> <prop key="hibernate.cache.use_query_cache">true</prop> <prop key="hibernate.use_sql_comments">true</prop> <prop key="hibernate.jdbc.batch_size">0</prop> <prop key="hibernate.jdbc.use_streams_for_binary">true</prop> </props> </property> <property name="dataSource" ref="dataSource"/> </bean> <bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler" lazy-init="true"> <property name="nativeJdbcExtractor"> <ref bean="nativeJdbcExtractor"/> </property> </bean> <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean" destroy-method="close"> <property name="jndiName"><value>com.bam.touch</value></property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <bean id="txServiceProxyTemplate" abstract="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager" ref="transactionManager" /> <property name="transactionAttributes"> <props> <prop key="save">PROPAGATION_REQUIRED</prop> <prop key="load">PROPAGATION_REQUIRED,readOnly</prop> <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop> </props> </property> </bean> <bean id="txProxyTemplate" abstract="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager" ref="transactionManager" /> <property name="transactionAttributes"> <props> <prop key="attach">PROPAGATION_REQUIRED</prop> <prop key="save*">PROPAGATION_REQUIRED</prop> <prop key="delete*">PROPAGATION_REQUIRED</prop> <prop key="create*">PROPAGATION_REQUIRED</prop> <prop key="replicate*">PROPAGATION_REQUIRED</prop> <prop key="getGuaranteed*">PROPAGATION_REQUIRED</prop> <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="load*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop> </props> </property> </bean>
Application-service.xmlCode:<bean id="queryDAO" parent="txProxyTemplate" > <property name="target" ref="queryDAOTarget" /> </bean> <bean id="queryDAOTarget" class="com.biogenidec.ttp.dao.hibernate.QueryDAOHibernate" > <property name="sessionFactory" ref="sessionFactory" /> </bean>
My question is how hibernate session is created and how is it passed on to the service, dao layers? When is the session destroyed?Code:<bean id="queryService" parent="txServiceProxyTemplate" > <property name="target" ref="queryServiceTarget" /> </bean> <bean id="queryServiceTarget" class="com.biogenidec.ttp.service.QueryService" > <property name="queryDAO" ref="queryDAO" /> </bean>
Thanks


Reply With Quote