bonjour
J'expérimente un petit problème de configuration de Spring et j'aimeriez que vous m'aidiez si possible...
J'ai cru comprendre que pour bien faire les choses dans une application, on peut injecter les sessionFactory d'hibernate à l'aide de Spring IOC (dites-moi si je me trompe)
J'ai donc fait ceci et celà semble avoir correctement été fait puisque j'ai alors obtenu le message d'erreur :
org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
En parcourant le net, j'ai alors cru comprendre qu'il faudrait fournir un "transactional scope". Est-ce exact ? Que dois-je faire sachant que je ne désire pas utiliser les fonctionnalités de persistance de Spring ?
merci
Mon ApplicationContext.xml
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66 <?xml version="1.0" encoding="UTF-8"?> <!-- <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"> --> <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-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> <!-- Datasource that works in any application server You could easily use J2EE data source instead if this were running inside of a J2EE container. --> <bean id="dataSource" class="org.apache.tomcat.dbcp.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName"> <value>com.mysql.jdbc.Driver</value> </property> <property name="url"> <value>jdbc:mysql://localhost/maDB</value> </property> <property name="username"> <value>root</value> </property> <property name="password"> <value>test</value> </property> </bean> <!-- Hibernate SessionFactory --> <bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="configLocation"> <value>classpath:hibernate.cfg.xml</value> </property> </bean> <bean id="paysDao" class="com.company.paysApp.dao.impl.PaysDaoImpl"> <property name="sessionFactory"> <ref local="mySessionFactory"/> </property> </bean> <!-- COMMENTAIRES <tx:advice id="txAdvice" transaction-manager="txManager"> <tx:attributes> <tx:method name="get*" read-only="true"/> <tx:method name="*"/> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut id="paysDaoOperation" expression="execution(* com.company.paysApp.dao..*.*(..))"/> <aop:advisor advice-ref="txAdvice" pointcut-ref="paysDaoOperation"/> </aop:config> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="dataSource" ref="dataSource"/> <property name="sessionFactory" ref="mySessionFactory"/> </bean> --> </beans>
Partager