Wednesday, 4 July 2018

Session factory configuration in spring

<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">

<property name="jndiName" value="jdbc/TEST" />

</bean>



<bean id="hibernateSessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">

<property name="dataSource" ref="dataSource"></property>

<property name="packagesToScan" value="com.test.model"></property>

<property name="hibernateProperties">

<props>

<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>

<prop key="hibernate.show_sql">false</prop>

<prop key="hibernate.bytecode.use_reflection_optimizer">false</prop>

<prop key="hibernate.search.autoregister_listeners">false</prop>

<prop key="hibernate.connection.release_mode">after_transaction</prop>

<prop key="hibernate.transaction.auto_close_session">false</prop>

</props>

</property>

</bean>




<bean id="transactionManager"

class="org.springframework.orm.hibernate5.HibernateTransactionManager">

<property name="sessionFactory" ref="hibernateSessionFactory"></property>

</bean>




<tx:annotation-driven transaction-manager="transactionManager"/>

No comments:

Post a Comment