Pb chargement du fichier hibernate.cfg.xml
Bonjour,
Voici le contenu de ce fichier :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| <?xml version="1.0"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@blabla.bla.fr:PORT:BLA</property>
<property name="connection.username">user</property>
<property name="connection.password">password</property>
<property name="show_sql">true</property>
<property name="dialect">net.sf.hibernate.dialect.Oracle9Dialect</property>
<!-- Hibernate configuration -->
<property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
<property name="query.imports net.sf.hibernate.test">net.sf.hibernate.eg</property>
<property name="c3p0.min_size">5</property>
<property name="c3p0.max_size">20</property>
<property name="c3p0.timeout">1800</property>
<property name="c3p0.max_statements">50</property>
<mapping resource="src/mapping.hbm.xml"/>
</session-factory>
</hibernate-configuration> |
Je charge le contenu de ce fichier lors de la récupération de mon sessionFactory :
Code:
1 2 3 4 5 6 7 8
| /** Gets local sessionFactory */
private static SessionFactory getLocalSessionFactory()
throws HibernateException {
URL url = SessionManager.class.getClassLoader().getResource("hibernate.cfg.xml");
Configuration config = new Configuration().addURL(url);
config.addURL(SessionManager.class.getClassLoader().getResource("mapping.hbm.xml"));
return config.buildSessionFactory();
} |
Premier truc louche : je suis obligé de forcer le chargement de mon fichier de mapping (en rouge), visiblement ce n'est pas fait automatiquement, pourtant la ressource est déclarée dans le fichier de config xml (hibernate.cfg.xml).
Bref je force et ça me charge le mapping, l'objet config contient toutes mes classes. Seulement dès la première requête, j'obtiens le message suivant :
Code:
Cause: java.lang.UnsupportedOperationException: The user must supply a JDBC connection
Une idée?