Bonjour,
J'utilise Hibernate et spring pour faire des appels à une base de données.
Mes requêtes d'insert semblent fonctionner correctement, mais par contre, toutes mes requêtes en lecture semblent planter au bout d'une dizaine d'appel, pas top.
Je vous mets ma configuration ci dessous :
Si j'enlève la ligne
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <!-- DataSource Definition --> <bean id="dataSourceID" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName"> <value>com.mysql.jdbc.Driver</value> </property> <property name="url"> <value>jdbc:mysql://localhost/topsite</value> </property> <property name="username"> <value>root</value> </property> <property name="password"> <value></value> </property> </bean> <!-- Hibernate SessionFactory Definition --> <bean id="sessionFactoryID" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="mappingResources"> <list> <value>com/cestpasdur/donnees/topsite.hbm.xml</value> <value>com/cestpasdur/donnees/ThemeTopsite.hbm.xml</value> <value>com/cestpasdur/donnees/Site.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="hibernate.show_sql">true</prop> </props> </property> <property name="dataSource"> <ref bean="dataSourceID" /> </property> </bean> <!-- Spring Data Access Exception Translator Defintion --> <bean id="jdbcExceptionTranslatorID" class="org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator"> <property name="dataSource"> <ref bean="dataSourceID" /> </property> </bean> <!-- Hibernate Template Defintion --> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"> <property name="sessionFactory"> <ref bean="sessionFactoryID" /> </property> <property name="jdbcExceptionTranslator"> <ref bean="jdbcExceptionTranslatorID" /> </property> </bean> <!-- Hibernate Transaction Manager Definition --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"> <ref local="sessionFactoryID" /> </property> </bean> <!-- ========================= Start of DAO DEFINITIONS ========================= --> <!-- Topsite DAO Definition: Hibernate implementation --> <bean id="topsiteDao" class="com.cestpasdur.dao.GenericDaoHibernateImpl"> <constructor-arg> <value>com.cestpasdur.donnees.Topsite</value> </constructor-arg> <property name="sessionFactory"> <ref bean="sessionFactoryID"/> </property> </bean> <!-- ========================= Start of SERVICE DEFINITIONS ========================= --> <bean id="serviceTopsiteTarget" class="com.cestpasdur.services.ServiceTopsite"> <property name="dao" ref="topsiteDao" /> </bean> <bean id="serviceTopsite" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager"> <ref local="transactionManager" /> </property> <property name="target"> <ref local="serviceTopsiteTarget" /> </property> <property name="transactionAttributes"> <props> <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="create*">PROPAGATION_REQUIRED</prop> <prop key="save*">PROPAGATION_REQUIRED</prop> <prop key="update*">PROPAGATION_REQUIRED</prop> <prop key="delete*">PROPAGATION_REQUIRED</prop> </props> </property> </bean> </beans>Je peux faire des appels (enfin une dizaine)
Code : Sélectionner tout - Visualiser dans une fenêtre à part <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
sinon, ca m'affiche l'erreur org.hibernate.LazyInitializationException: could not initialize proxy - no Session
Je dois mal gérer la session hibernate quelque part, mais où ?
J'ai utilisé la page ici pour ma config dao :
http://www.ibm.com/developerworks/ja...enericdao.html
Si quelqu'un a déjà eu le problème![]()
Partager