Salut,j'ai un probleme avec Hibernate lorsque je l'utilise sous JavaEE pour mes developpement Web ça fonctionne sans problème mais lorsque je suis sur JavaSE il me donne des bugs.
Code Java:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
  Session session=(new Configuration().configure().buildSessionFactory()).openSession();
        Query qr=session.createQuery("SELECT p FROM Agent p");
        Iterator iagent=qr.iterate();
        while (iagent.hasNext()) {
            Agent agent = (Agent)iagent.next();
            System.out.println(agent.getNom());
 
        }
Message bug:
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
run:
126 [main] INFO org.hibernate.annotations.common.Version - Hibernate Commons Annotations 3.2.0.Final
133 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.6.10.Final
134 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found
138 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
141 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
201 [main] INFO org.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml
201 [main] INFO org.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml
268 [main] WARN org.hibernate.util.DTDEntityResolver - recognized obsolete hibernate namespace <a href="http://hibernate.sourceforge.net/" target="_blank">http://hibernate.sourceforge.net/</a>. Use namespace <a href="http://www.hibernate.org/dtd/" target="_blank">http://www.hibernate.org/dtd/</a> instead. Refer to Hibernate 3.6 Migration Guide!
295 [main] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : monpackage/Agent.hbm.xml
328 [main] WARN org.hibernate.util.DTDEntityResolver - recognized obsolete hibernate namespace <a href="http://hibernate.sourceforge.net/" target="_blank">http://hibernate.sourceforge.net/</a>. Use namespace <a href="http://www.hibernate.org/dtd/" target="_blank">http://www.hibernate.org/dtd/</a> instead. Refer to Hibernate 3.6 Migration Guide!
373 [main] INFO org.hibernate.cfg.Configuration - Configured SessionFactory: null
441 [main] INFO org.hibernate.cfg.HbmBinder - Mapping class: com.Agent.Agent -> agent
462 [main] INFO org.hibernate.cfg.Configuration - Hibernate Validator not found: ignoring
467 [main] INFO org.hibernate.cfg.search.HibernateSearchEventListenerRegister - Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled.
474 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
474 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 20
474 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - autocommit mode: false
483 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/test
484 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=root, password=****}
908 [main] INFO org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.MySQLDialect
928 [main] INFO org.hibernate.cfg.SettingsFactory - Database ->
       name : MySQL
    version : 5.5.21
      major : 5
      minor : 5
929 [main] INFO org.hibernate.cfg.SettingsFactory - Driver ->
       name : MySQL-AB JDBC Driver
    version : mysql-connector-java-5.1.23 ( Revision: ${bzr.revision-id} )
      major : 5
      minor : 1
930 [main] INFO org.hibernate.transaction.TransactionFactoryFactory - Using default transaction strategy (direct JDBC transactions)
932 [main] INFO org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
932 [main] INFO org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
932 [main] INFO org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
932 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC batch size: 15
932 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC batch updates for versioned data: disabled
933 [main] INFO org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled
933 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): enabled
933 [main] INFO org.hibernate.cfg.SettingsFactory - Connection release mode: auto
936 [main] INFO org.hibernate.cfg.SettingsFactory - Maximum outer join fetch depth: 2
936 [main] INFO org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
936 [main] INFO org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
936 [main] INFO org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
936 [main] INFO org.hibernate.cfg.SettingsFactory - Order SQL inserts for batching: disabled
937 [main] INFO org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
939 [main] INFO org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
939 [main] INFO org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
939 [main] INFO org.hibernate.cfg.SettingsFactory - JPA-QL strict compliance: disabled
939 [main] INFO org.hibernate.cfg.SettingsFactory - Second-level cache: enabled
939 [main] INFO org.hibernate.cfg.SettingsFactory - Query cache: disabled
939 [main] INFO org.hibernate.cfg.SettingsFactory - Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory
940 [main] INFO org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled
940 [main] INFO org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled
944 [main] INFO org.hibernate.cfg.SettingsFactory - Statistics: disabled
945 [main] INFO org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
945 [main] INFO org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo
945 [main] INFO org.hibernate.cfg.SettingsFactory - Named query checking : enabled
945 [main] INFO org.hibernate.cfg.SettingsFactory - Check Nullability in Core (should be disabled when Bean Validation is on): enabled
975 [main] INFO org.hibernate.impl.SessionFactoryImpl - building session factory
981 [main] INFO org.hibernate.type.BasicTypeRegistry - Type registration [wrapper_characters_clob] overrides previous : org.hibernate.type.CharacterArrayClobType@18ce197
981 [main] INFO org.hibernate.type.BasicTypeRegistry - Type registration [characters_clob] overrides previous : org.hibernate.type.PrimitiveCharacterArrayClobType@2eab5b
981 [main] INFO org.hibernate.type.BasicTypeRegistry - Type registration [blob] overrides previous : org.hibernate.type.BlobType@1f4075c
981 [main] INFO org.hibernate.type.BasicTypeRegistry - Type registration [java.sql.Blob] overrides previous : org.hibernate.type.BlobType@1f4075c
981 [main] INFO org.hibernate.type.BasicTypeRegistry - Type registration [clob] overrides previous : org.hibernate.type.ClobType@f3a6e
981 [main] INFO org.hibernate.type.BasicTypeRegistry - Type registration [java.sql.Clob] overrides previous : org.hibernate.type.ClobType@f3a6e
981 [main] INFO org.hibernate.type.BasicTypeRegistry - Type registration [materialized_clob] overrides previous : org.hibernate.type.MaterializedClobType@1c51a26
981 [main] INFO org.hibernate.type.BasicTypeRegistry - Type registration [wrapper_materialized_blob] overrides previous : org.hibernate.type.WrappedMaterializedBlobType@137cb3d
981 [main] INFO org.hibernate.type.BasicTypeRegistry - Type registration [materialized_blob] overrides previous : org.hibernate.type.MaterializedBlobType@1eba
Exception in thread "main" org.hibernate.MappingException: entity class not found: com.Agent.Agent
	at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:125)
	at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:125)
	at org.hibernate.tuple.PropertyFactory.getGetter(PropertyFactory.java:191)
	at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:67)
	at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:135)
	at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:485)
	at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:133)
	at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:84)
	at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:286)
	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1872)
	at javaapplication9.JavaApplication9.main(JavaApplication9.java:27)
Caused by: java.lang.ClassNotFoundException: com.Agent.Agent
	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:190)
	at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:192)
	at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:122)
	... 9 more
Java Result: 1
BUILD SUCCESSFUL (total time: 3 seconds)