slt tout le monde,
voila j'ai un petit problème, j'ai réalisé une application qui utilise hibernate, mais je n'arrive pas à l'exécuter, j'ai tjrs cette erreur.
j'utilise NtBeans 6.5
Help7 avr. 2009 18:01:35 org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2.5
7 avr. 2009 18:01:35 org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
7 avr. 2009 18:01:35 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
7 avr. 2009 18:01:35 org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
7 avr. 2009 18:01:35 org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
7 avr. 2009 18:01:35 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
7 avr. 2009 18:01:36 org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : com/test/rsyncBean/Compte.hbm.xml
7 avr. 2009 18:01:36 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: com.test.rsyncBean.Compte -> compte
7 avr. 2009 18:01:36 org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : com/test/rsyncBean/Personne.hbm.xml
7 avr. 2009 18:01:36 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: com.test.rsyncBean.Personne -> personne
7 avr. 2009 18:01:36 org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
7 avr. 2009 18:01:36 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
7 avr. 2009 18:01:36 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 1
7 avr. 2009 18:01:36 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
7 avr. 2009 18:01:36 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/rsyncdb
7 avr. 2009 18:01:36 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=rsync, password=****}
7 avr. 2009 18:01:36 org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: MySQL, version: 5.0.77-community-nt
7 avr. 2009 18:01:36 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.6 ( Revision: ${svn.Revision} )
7 avr. 2009 18:01:36 org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.MySQLInnoDBDialect
7 avr. 2009 18:01:36 org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Using default transaction strategy (direct JDBC transactions)
7 avr. 2009 18:01:36 org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
7 avr. 2009 18:01:36 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
7 avr. 2009 18:01:36 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
7 avr. 2009 18:01:36 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch size: 15
7 avr. 2009 18:01:36 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch updates for versioned data: disabled
7 avr. 2009 18:01:36 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
7 avr. 2009 18:01:36 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): enabled
7 avr. 2009 18:01:36 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: auto
7 avr. 2009 18:01:36 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Maximum outer join fetch depth: 2
7 avr. 2009 18:01:36 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
ma classe Personnemon fichier mapping hibernate
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 /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package com.test.rsyncBean; import com.test.*; /** * * @author zenadm */ public class Personne { private String idPersonne; private String perIdPersonne; private String nom; private String prenom; private String email; private String tel; private Compte compte; public Personne(){ } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getNom() { return nom; } public void setNom(String nom) { this.nom = nom; } public String getPrenom() { return prenom; } public void setPrenom(String prenom) { this.prenom = prenom; } public Compte getCompte() { return compte; } public void setCompte(Compte compte) { this.compte = compte; } }puis mon fichier conf
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="com.test.rsyncBean.Personne" table="personne"> <id column="ID_PERSONNE" name="idPersonne" type="int"> <generator class="native"/> </id> <property column="PER_ID_PERSONNE" name="perIdPersonne" not-null="true" type="string"/> <property column="NOM" name="nom" not-null="true" type="string"/> <property column="PRENOM" name="prenom" not-null="true" type="string"/> <property column="EMAIL" name="email" not-null="true" type="date"/> <property column="TEL" name="tel" not-null="false" type="double"/> </class> </hibernate-mapping>
et pour exécuter tout ça j'utilise le deux classes surventes :
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 <?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> <!-- SQL dialect --> <property name="hibernate.dialect"> org.hibernate.dialect.MySQLInnoDBDialect</property> <!-- Database connection settings --> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/rsyncdb</property> <property name="hibernate.connection.username">rsgegrgync</property> <property name="hibernate.connection.password">qgrzereqrn4yougrg</property> <!-- JDBC connection pool (use the built-in) --> <property name="hibernate.connection.pool_size">1</property> <!-- Echo all executed SQL to stdout --> <property name="hibernate.show_sql">true</property> <!-- Enable Hibernate's automatic session context management --> <property name="hibernate.current_session_context_class">thread</property> <!-- Drop and re-create the database schema on startup --> <property name="hibernate.hbm2ddl.auto">create</property> <mapping resource="com/test/rsyncBean/Personne.hbm.xml"/> </session-factory> </hibernate-configuration>
enfin ma classe main:
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 /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package com.test.rsyncModel; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; /** * * @author zenadm */ //import org.hibernate.*; //import org.hibernate.cfg.*; public class HibernateUtil { private static final SessionFactory sessionFactory; static { try { // Create the SessionFactory from hibernate.cfg.xml sessionFactory = new Configuration().configure().buildSessionFactory(); } catch (Throwable ex) { // Make sure you log the exception, as it might be swallowed System.err.println("Initial SessionFactory creation failed." + ex); throw new ExceptionInInitializerError(ex); } } public static SessionFactory getSessionFactory() { return sessionFactory; } }
Help!!!!!!!!!!
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 /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package com.test.rsyncModel; import com.test.rsyncBean.Personne; import org.hibernate.Session; public class EventManager { public static void main(String[] args) { EventManager mgr = new EventManager(); mgr.getPersonne(); System.out.println(mgr); HibernateUtil.getSessionFactory().close(); } private String getPersonne() { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); Personne thePersonne = new Personne(); thePersonne.getNom(); thePersonne.getPrenom(); session.save(thePersonne); session.getTransaction().commit(); return thePersonne.getNom()+thePersonne.getPrenom(); } }
Partager