Bonjour,

Je suis face à un problème assez bloquant; aucunes de mes modification n'est répercutée dans ma base de données.
Par contre le temps de l'exécution de l'application tout semble fonctionner correctement, comme si hibernate travaillait sur un db en mémoire et non pas sur ma db physique.

Pour configurer hibernate, j'utilise un fichier xml et un fichier de properties personnel. J'ai une petite partie de code chargée de "fusionner" mon fivhier de properties dans un objet Properties utilisable par Hibernate.

hibernate.cfg.xml :
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.pool_size">2</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="hibernate.hbm2ddl.auto">update</property>

</session-factory>
</hibernate-configuration>
Le code de "fusion" :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
Properties hibernateProperties = new Properties();
		String url = new StringBuilder("jdbc:postgresql://")
			.append(properties.getProperty("jdbc.host.url"))
			.append(":").append(properties.getProperty("jdbc.host.port","5432"))
			.append("/").append(properties.getProperty("jdbc.db.name","MYDB"))
			.toString();
		hibernateProperties.put("hibernate.connection.url", url);
		hibernateProperties.put("hibernate.connection.username", properties.get("jdbc.user.name"));
		hibernateProperties.put("hibernate.connection.password", properties.get("jdbc.user.password"));
 
		hibUtils = new HibernateUtil(hibernateProperties, new File("./conf/hibernate.cfg.xml"));
Ma classe Hibernate Util :
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
public HibernateUtil(Properties properties, File hibernateCfg) {			
		Configuration cfg = new Configuration()
			// Mappings		
			.addResource("...")
 
			// Dynamic properties (user editables : url, username, password)
			.setProperties(properties)
 
			// Core properties (from hibernate.cfg.xml)
			.configure(hibernateCfg);
		try {
			sessionFactory = cfg.buildSessionFactory();
		} catch (Throwable e) {
			throw new ExceptionInInitializerError(e);
		}
	}
La configuration fonctionne (Hibernate se connecte et récupère le contenu de ma db) mais, comme dis au début, aucune modification n'est écrite dans la db.

Voici un exemple de logs crées par Hibernate lors de la mise à jour d'un objet :
UPDATING resource
2008-09-09 14:17:15,359 DEBUG [xx.yy.zz.dao.impl.spring.hibernate.GenericHibernateDao] - Updating Resource 'Resource /testresource/* with roles : [xx.yy.commons.beans.Role@719f1f, xx.yy.commons.beans.Role@1474e45, xx.yy.commons.beans.Role@63a721]'.
2008-09-09 14:17:15,359 DEBUG [org.springframework.orm.hibernate3.SessionFactoryUtils] - Opening Hibernate Session
2008-09-09 14:17:15,359 DEBUG [org.hibernate.impl.SessionImpl] - opened session at timestamp: 12209626353
2008-09-09 14:17:15,375 DEBUG [org.hibernate.event.def.DefaultSaveOrUpdateEventListener] - updating detached instance
2008-09-09 14:17:15,375 DEBUG [org.hibernate.event.def.DefaultSaveOrUpdateEventListener] - updating [xx.yy.zz.security.Resource#/testresource/*]
2008-09-09 14:17:15,375 DEBUG [org.hibernate.event.def.DefaultSaveOrUpdateEventListener] - updating [xx.yy.zz.security.Resource#/testresource/*]
2008-09-09 14:17:15,390 DEBUG [org.springframework.orm.hibernate3.HibernateTemplate] - Eagerly flushing Hibernate session
2008-09-09 14:17:15,390 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] - flushing session
2008-09-09 14:17:15,390 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] - processing flush-time cascades
2008-09-09 14:17:15,406 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] - dirty checking collections
2008-09-09 14:17:15,406 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] - Flushing entities and processing referenced collections
2008-09-09 14:17:15,406 DEBUG [org.hibernate.event.def.DefaultFlushEntityEventListener] - Updating entity: [xx.yy.zz.security.Resource#/testresource/*]
2008-09-09 14:17:15,406 DEBUG [org.hibernate.engine.Collections] - Collection found: [xx.yy.zz.security.Resource.roles#/testresource/*], was: [xx.yy.zz.security.Resource.roles#/testresource/*] (initialized)
2008-09-09 14:17:15,406 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] - Processing unreferenced collections
2008-09-09 14:17:15,406 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] - Scheduling collection removes/(re)creates/updates
2008-09-09 14:17:15,406 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] - Flushed: 0 insertions, 1 updates, 0 deletions to 1 objects
2008-09-09 14:17:15,406 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] - Flushed: 0 (re)creations, 0 updates, 0 removals to 1 collections
2008-09-09 14:17:15,406 DEBUG [org.hibernate.pretty.Printer] - listing entities:
2008-09-09 14:17:15,406 DEBUG [org.hibernate.pretty.Printer] - xx.yy.zz.security.Resource{description=All resources relative to the student folder, roles=[xx.yy.commons.beans.Role#Utilisateurs, xx.yy.commons.beans.Role#Administrateurs, xx.yy.commons.beans.Role#Demonstration], url=/testresource/*}
2008-09-09 14:17:15,406 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] - executing flush
2008-09-09 14:17:15,406 DEBUG [org.hibernate.jdbc.ConnectionManager] - registering flush begin
2008-09-09 14:17:15,421 DEBUG [org.hibernate.persister.entity.AbstractEntityPersister] - Updating entity: [xx.yy.zz.security.Resource#/testresource/*]
2008-09-09 14:17:15,421 DEBUG [org.hibernate.jdbc.AbstractBatcher] - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2008-09-09 14:17:15,421 DEBUG [org.hibernate.jdbc.ConnectionManager] - opening JDBC connection
2008-09-09 14:17:15,421 DEBUG [org.hibernate.connection.DriverManagerConnectionProvider] - total checked-out connections: 0
2008-09-09 14:17:15,421 DEBUG [org.hibernate.connection.DriverManagerConnectionProvider] - using pooled JDBC connection, pool size: 0
2008-09-09 14:17:15,421 DEBUG [org.hibernate.SQL] - update resources set description=? where url=?
Hibernate:
update resources
set description=?
where url=?
2008-09-09 14:17:15,421 DEBUG [org.hibernate.jdbc.AbstractBatcher] - preparing statement
2008-09-09 14:17:15,421 DEBUG [org.hibernate.persister.entity.AbstractEntityPersister] - Dehydrating entity: [xx.yy.zz.security.Resource#/testresource/*]
2008-09-09 14:17:15,421 DEBUG [org.hibernate.type.StringType] - binding 'All resources relative to the student folder' to parameter: 1
2008-09-09 14:17:15,421 DEBUG [org.hibernate.type.StringType] - binding '/testresource/*' to parameter: 2
2008-09-09 14:17:15,421 DEBUG [org.hibernate.jdbc.AbstractBatcher] - Executing batch size: 1
2008-09-09 14:17:15,437 DEBUG [org.hibernate.jdbc.AbstractBatcher] - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2008-09-09 14:17:15,437 DEBUG [org.hibernate.jdbc.AbstractBatcher] - closing statement
2008-09-09 14:17:15,437 DEBUG [org.hibernate.jdbc.ConnectionManager] - registering flush end
2008-09-09 14:17:15,437 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] - post flush
2008-09-09 14:17:15,437 DEBUG [org.springframework.orm.hibernate3.SessionFactoryUtils] - Closing Hibernate Session
2008-09-09 14:17:15,437 DEBUG [org.hibernate.impl.SessionImpl] - closing session
2008-09-09 14:17:15,437 DEBUG [org.hibernate.jdbc.ConnectionManager] - performing cleanup
2008-09-09 14:17:15,437 DEBUG [org.hibernate.jdbc.ConnectionManager] - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
2008-09-09 14:17:15,437 DEBUG [org.hibernate.connection.DriverManagerConnectionProvider] - returning connection to pool, pool size: 1
2008-09-09 14:17:15,437 DEBUG [org.hibernate.jdbc.JDBCContext] - after transaction completion
2008-09-09 14:17:15,437 DEBUG [org.hibernate.jdbc.ConnectionManager] - aggressively releasing JDBC connection
2008-09-09 14:17:15,437 DEBUG [org.hibernate.impl.SessionImpl] - after transaction completion
L'un d'entre vous à t'il une idée ?

Merci