Hello,
Je test hibernate, mon programme ne me met pas d'erreur (juste des logs), mais aucune donnée n'est ajoutée dans ma base... Je ne comprends pas pourquoi?
Ma config:
MySQL dernière version
Hibernate pareil
Eclipse Ganymede
jdk6
Mes logs:
10:12:53 [ INFO] [org.hibernate.cfg.Environment] (<clinit>:474): Hibernate 3.1 rc2
10:12:53 [ INFO] [org.hibernate.cfg.Environment] (<clinit>:504): hibernate.properties not found
10:12:53 [ INFO] [org.hibernate.cfg.Environment] (<clinit>:520): using CGLIB reflection optimizer
10:12:53 [ INFO] [org.hibernate.cfg.Environment] (<clinit>:550): using JDK 1.4 java.sql.Timestamp handling
10:12:53 [ INFO] [org.hibernate.cfg.Configuration] (configure:1257): configuring from resource: /hibernate.cfg.xml
10:12:53 [ INFO] [org.hibernate.cfg.Configuration] (getConfigurationInputStream:1234): Configuration resource: /hibernate.cfg.xml
10:12:53 [DEBUG] [org.hibernate.util.DTDEntityResolver] (resolveEntity:42): trying to locate http://hibernate.sourceforge.net/hib...ration-3.0.dtd in classpath under org/hibernate/
10:12:53 [DEBUG] [org.hibernate.util.DTDEntityResolver] (resolveEntity:56): found http://hibernate.sourceforge.net/hib...ration-3.0.dtd in classpath
10:12:53 [DEBUG] [org.hibernate.cfg.Configuration] (addProperties:1218): hibernate.connection.driver_class=com.mysql.jdbc.Driver
10:12:53 [DEBUG] [org.hibernate.cfg.Configuration] (addProperties:1218): hibernate.connection.password=<password>
10:12:53 [DEBUG] [org.hibernate.cfg.Configuration] (addProperties:1218): hibernate.connection.url=jdbc:mysql://127.0.0.1:3306/<db_name>
10:12:53 [DEBUG] [org.hibernate.cfg.Configuration] (addProperties:1218): hibernate.connection.username=root
10:12:53 [DEBUG] [org.hibernate.cfg.Configuration] (addProperties:1218): hibernate.dialect=org.hibernate.dialect.MySQLDialect
10:12:53 [DEBUG] [org.hibernate.cfg.Configuration] (parseMappingElement:1413): null<-org.dom4j.tree.DefaultAttribute@12558d6 [Attribute: name resource value "RawMessage.hbm.xml"]
10:12:53 [ INFO] [org.hibernate.cfg.Configuration] (addResource:460): Reading mappings from resource: RawMessage.hbm.xml
10:12:53 [DEBUG] [org.hibernate.util.DTDEntityResolver] (resolveEntity:42): trying to locate http://hibernate.sourceforge.net/hib...apping-2.0.dtd in classpath under org/hibernate/
10:12:53 [DEBUG] [org.hibernate.util.DTDEntityResolver] (resolveEntity:49): http://hibernate.sourceforge.net/hib...apping-2.0.dtd not found in classpath
10:12:53 [ERROR] [org.hibernate.util.DTDEntityResolver] (resolveEntity:51): Don't use old DTDs, read the Hibernate 3.x Migration Guide!
Ma classe persistante:
Mon code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 public class RawMessage { private int id; private String uri; private Date insertionDate; private Account account; // ... getters et setters publics pour chaque variable...
Mon fichier de conf hibernate:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 Session session = HibernateUtil.currentSession(); Transaction tx = session.beginTransaction(); session.save(rawMessage); tx.commit(); HibernateUtil.closeSession();
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.password">pass</property> <property name="hibernate.connection.url">jdbc:mysql://127.0.0.1:3306/db_name</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> <mapping resource="RawMessage.hbm.xml" /> </session-factory> </hibernate-configuration>
Partager