Dear,
I'm using an application server (wasce) connection pool trought Hibernate to connect an Oracle database.
When I do a "getSession().save(Obj)" , the object is saved in my Hibernate session, but it is not saved in the database even with a flush.
To synchronize the database, i had to add a "getSession().connection().setAutoCommit(true);" and now, it works.
However, Session.connection() is now deprecated and I think it's not the good way to configure hibernate properly anyway..
Could you tell me a good alternative to configure my connection pool ?
Here is my config.. (PS: I'm using spring)
hibernate.hbm.xml :
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.datasource">java:comp/env/jdbc/oracleJNDI</property>
<property name="default_schema">MYFIRSTSCHEMA</property>
<property name="current_session_context_class">thread</property>
<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
+MAPPING...
</session-factory>
</hibernate-configuration>
springmvc-servlet.xml
Code:
<!-- DB Transaction definition -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean id="transactionProxy" abstract="true"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="insert*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_REQUIRED, readOnly</prop>
</props>
</property>
</bean>
<!-- sessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
<!-- <property name="mappingLocations">
<list>
<value>classpath:hibernate.cfg.xml</value>
<value>classpath:hibernate.minterne.cfg.xml</value>
</list>
</property>-->
<property name="configurationClass">
<value>org.hibernate.cfg.AnnotationConfiguration</value>
</property>
</bean>
<!-- END DB Transaction definition -->
Thanks a lot.