J'ai réussi à bien configurer le tout cependant j'ai un problème : À chaque fois que je démarre le serveur, je peux faire exaxtement 3 accès à la base de données, la 4ieme requête loop toujours indéfiniment. Je ne sais pas si quelqu'un a une idée du problème...

J'utilise:

Hibernate 3
MySQL 4.1
Common DBCP
Tomcat 5.5
Voici ma config dans hibernate.cfg.xml:
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
<hibernate-configuration>
 
<session-factory>
 
	<property name="connection.datasource">java:comp/env/jdbc/InoukDB</property>
 
	<!--### Apache DBCP Connection Pool ###-->
	<!--connection pool-->
	<property name="hibernate.dbcp.maxActive">10</property>
	<property name="hibernate.dbcp.whenExhaustedAction">1</property>
	<property name="hibernate.dbcp.maxWait">100</property>
	<property name="hibernate.dbcp.maxIdle">10</property>
 
	<mapping resource="mapping/Departement.hbm.xml" />
	<mapping resource="mapping/Poste.hbm.xml" />
	<mapping resource="mapping/Staff.hbm.xml" />
...
 
</session-factory>
 
</hibernate-configuration>
Voici mon code pour initialiser ma connexion dans une classe "Helper":
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
 
 
public class HibernateHelper {
 
	private static final SessionFactory sessionFactory;
	private static final ThreadLocal threadSession = new ThreadLocal();
	private static final ThreadLocal threadTransaction = new ThreadLocal();
	private static DataSource ds = null;
 
	static{
		try{
            Configuration cfg = new Configuration();
            cfg.configure("mapping/hibernate.cfg.xml");
            sessionFactory = cfg.buildSessionFactory();
 
            Context ctx = new InitialContext();
            ds = (DataSource)ctx.lookup("java:comp/env/jdbc/InoukDB");
 
	    } catch (Throwable ex) {
	        ex.printStackTrace();
	        throw new ExceptionInInitializerError(ex);
	      }
	}
 
    /**
     * Return a unique session object
     *
     */
    public static Session getSession() {
 
    	Session session = (Session) threadSession.get();
 
    	//Open a new Session, if this thread has none yet
    	try{
    		if(session == null){
 
    			try {
 
					session = sessionFactory.openSession( ds.getConnection() );
	    			threadSession.set(session);
 
				} catch (SQLException e) {
					e.printStackTrace();
				}
 
    		}
    	}
    	catch(HibernateException ex){
    		ex.getMessage();
    	}
 
    	return session;
    }
 
...
Bon voila en espérant de l'aide