salut les amis
j'utilise oracle et hibernate avec spring et struts mais quand je fais un save() les données ne s’enregistrent pas dans ma base instantanément. c'est juste lors du prochain chargement du context (d’après le log d'apache après chaque changement dans l'un des fichier de mon application) que les données apparaissent !!!
donc comment faire pour enregistrer les données immédiatement ?.
voici mes configurations :
autentification.hbm.xml :
l'appel de save dans la fonction execute() de struts dans le form action :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 <hibernate-mapping> <class name="POJOs.Autentification" table="AUTENTIFICATION" schema="WS" > <id name="id" type="int"> <column name="ID"/> <generator class="increment"/> </id> <property name="login" type="string"> <column name="LOGIN" length="30" /> </property> <property name="password" type="string"> <column name="PASSWORD" length="30" /> </property> </class> </hibernate-mapping>
applicationContext.xml de spring :
Code : Sélectionner tout - Visualiser dans une fenêtre à part wsservice.addUser(new Autentification(logfrm.getLogin(),logfrm.getPassword()));
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
37
38
39
40
41
42
43
44
45
46
47
48 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> <bean id="WsService" class="DamService.WsServiceImp" > <property name="wsdao" ref="wsdao" /> </bean> <bean id="wsdao" class="DamDAO.WsDaoImp" > <property name="hibernateTemplate" ref="hibernateTemplate"></property> </bean> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="configLocation" value="classpath:hibernate.cfg.xml"> </property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <bean name="/LoginAction" class="Struts.LoginAction"> <property name="wsservice" ref="WsService"></property> </bean> </beans>
Partager