1 pièce(s) jointe(s)
Problème de transaction Spring Hibernate
Bonjour,
J'ai rencontre actuellement un problème avec la gestion des transactions puisque les insertions que je fais en base sont effectives seulement lorsque je stoppe le serveur d'application (comme si je ne faisais aucun commit).
Ci dessous ma conf Spring
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/xxxx"/>
</bean>
<tx:annotation-driven transaction-manager="txManager"/>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="mappingResources">
<list>
<value>lu/ptc/c2p/hibernate/hbm/Utilisateurs.hbm.xml</value>
<value>lu/ptc/c2p/hibernate/hbm/at/Avt.hbm.xml</value>
...
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.generate_statistics">false</prop>
<!-- prop key="hibernate.hbm2ddl.auto">update</prop>-->
</props>
</property>
<property name="dataSource">
<ref bean="dataSource"/>
</property>
</bean>
<bean id="avtDao" class="lu.ptc.at.dao.hibernate.AvtDaoHibernate">
<property name="sessionFactory" ref="sessionFactory"/>
</bean> |
J'ai donc un service avec une annotation pour faire office de point-cut et me permettre de définir la transaction:
Code:
1 2 3 4 5 6 7 8 9
|
@Transactional(readOnly = false, propagation=Propagation.REQUIRED)
public TransfertLotAt createLotAvtService() {
TransfertLotAt transfertLotAt = new TransfertLotAt();
transfertLotAt.setDhcre(new Date());
transfertLotAt.setStatut(TransfertLotAt.STATUT_INIT);
transfertLotATDao.save(transfertLotAt);
return transfertLotAt;
} |
Et enfin au niveau de ma DAO j'ai mis en place la méthode suivante:
Code:
1 2 3 4
|
public void save(Avt avt) {
getHibernateTemplate().save(avt);
} |
J'ai essayé de faire la même chose par configuration xml (avec définition des points-cut) en lieu et place des annotations et j'arrive au même comportement.
Je vois pourtant bien dans mes logs les begin/commit de transaction alors je ne sais pas trop d'ou peut venir le problème. Je vous joins un moceaux des logs.