Bonjour,
Après avoir mis en place ce qu'il fallait dans la configuration de mon application :
Code xml : 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 <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" <a href="http://www.springframework.org/schema/beans" target="_blank">http://www.springframework.org/schema/beans</a> http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="url" value="jdbc:mysql://192.168.0.2/" /> <property name="username" value="root" /> <property name="password" value="xxx" /> </bean> <bean id="sessionFactoryBean" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.MySQLDialect </prop> <prop key="hibernate.show_sql">true</prop> </props> </property> <property name="mappingResources"> <list> <value>mapping/user.hbm.xml</value> </list> </property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean> </beans>
J'ai un NullPointerException lors de l'appel dans ma DAO à la méthode getHibernateTemplate();
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 public UserDaoImpl() { ClassPathResource res = new ClassPathResource("osrApp.xml"); XmlBeanFactory factory = new XmlBeanFactory(res); sessionFactory = (SessionFactory) (factory.getBean("sessionFactoryBean")); } public void createUser(List<User> users) { for (User user : users) { this.getHibernateTemplate().save(user); } }
Me suis je trompé dans mon fichier de configuration ???
Je ne comprend vraiment pas !!!
Merci beaucoup,
Thomas
Partager