Version d'Hibernate : 3.2

J'ai une table "SITE_CONSOMMATION" qui est alimenté par import de fichier. Ainsi chaque élément de ma table a un lien vers une table "Flux" où l'on stocke les fichiers importés par l'utilisateur.

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-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.gdf.sialloc.collecte.domain">
	<class name="SiteConsommation" table="SITE_CONSOMMATION" lazy="false">
		<id name="id" column="ID_SITE_CONSOMMATION" type="long" unsaved-value="null">
			<generator class="sequence">
				<param name="sequence">SEQ_SITE_CONSOMMATION</param>
			</generator>
		</id>
		<version name="version" />
		<property name="dateCreation" column="DATECREATION" type="timestamp" update="false"/>
		<property name="dateModification" column="DATEMODIFICATION" type="timestamp" insert="false" />
		<property name="idUtilisateur" column="ID_UTILISATEUR" type="long" />
 
		<property name="codePoint" column="CODE_POINT" type="string" update="false"/>
		<many-to-one name="flux" class="com.gdf.sialloc.referentiel.domain.Flux" column="ID_FLUX" update="false"/>
		<many-to-one name="zone" class="com.gdf.sialloc.referentiel.domain.ZoneEquilibrage" column="ID_ZONE" lazy="false"/>
		<many-to-one name="client" class="com.gdf.sialloc.referentiel.domain.Client" column="ID_CLIENT"/>
	</class>
</hibernate-mapping>
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
<?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 package="com.gdf.sialloc.referentiel.domain">
	<class name="Flux" table="FLUX" lazy="false">
		<id name="id" column="ID_FLUX" type="long" 
			unsaved-value="null">
			<generator class="sequence">
				<param name="sequence">SEQ_FLUX</param>
			</generator>
		</id>
		<version name="version" />
		<property name="dateCreation" column="DATECREATION"
			type="timestamp" update="false"/>
		<property name="dateModification" column="DATEMODIFICATION"
			type="timestamp" insert="false" />
		<property name="idUtilisateur" column="ID_UTILISATEUR"
			type="long" />
		<property name="dateInsertion" column="DATE_INSERTION" type="timestamp"/>
		<property name="nomFlux" column="NOM_FLUX" type="string" />
		<property name="validite" column="VALIDITE" type="boolean" />
		<property name="correct" column="CORRECT" type="boolean" />
		<property name="publie" column="PUBLIE" type="boolean" />
		<property name="messageErreurBlob" column="MESSAGE_ERREUR" type="blob" update="false"/>
		<property name="fluxBlob" column="FLUX" type="blob" update="true"/>
		<many-to-one name="descripteurFlux" class="DescripteurFlux" column="ID_DESCRIPTEUR"/>	
		<many-to-one name="campagne" class="com.gdf.sialloc.referentiel.domain.Campagne" column="ID_CAMPAGNE"/>
		<many-to-one name="operateur" class="com.gdf.sialloc.referentiel.domain.Operateur" column="ID_OPERATEUR"/>
	</class>
</hibernate-mapping>

J'effectue un select dans la table des sites de consommation qui me remonte un certain nombre d'enregistrements.

La requête fonctionne correctement, mais lorsque j'affiche les trace sql je vois qu'après mon select Hibernate fait un update de l'objet "Flux".

Quelqu'un connaît ce cas et la solution pour qu'il n'y ait pas d'update ?

Je précise qu'aucune manipulation n'est fait des objets remontés pendant la session qui pourrait déclencher un update.

Merci.

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
public ArrayList loadSiteConsommation(Long pIdCampagne, Long pIdClient, Long pIdOperateur) {
		StringBuffer request = new StringBuffer( "" );
		ArrayList listSites = null;
		request.append("select site from Client as cl, SiteConsommation as site, Flux as flux, OperationObjet as lien, Operation as op ");
		request.append(" where op.id = lien.operation ");
		request.append(" and op.codeOperation = '").append(TypeOperation.OPE_IMPORT_SITE_CONSOMMATION ).append("'");
		request.append(" and flux.id = lien.idObjet");
		request.append(" and lien.className = 'com.gdf.sialloc.referentiel.domain.Flux'");
		request.append(" and flux.campagne = ").append( pIdCampagne );
		request.append(" and flux.operateur = ").append( pIdOperateur );
		request.append(" and flux.validite = ").append( Boolean.TRUE );
		request.append(" and site.flux = flux.id");
		if( pIdClient != null && pIdClient.longValue() > 0 ){
			request.append(" and site.client = ").append( pIdClient);
		}
		request.append(" and cl.id = site.client");
		request.append(" and op.dateCreation = ( select max( op2.dateCreation )");
		request.append(" from Operation as op2 , OperationObjet as lien2 , Flux as flux2" );
		request.append(" where op2.codeOperation = '").append(TypeOperation.OPE_IMPORT_SITE_CONSOMMATION ).append("'" );
		request.append(" and op2.id = lien2.operation " );
		request.append(" and lien2.className= 'com.gdf.sialloc.referentiel.domain.Flux'");
		request.append(" and flux2.id = lien2.idObjet" );
		request.append(" and flux2.validite = ").append( Boolean.TRUE );
		request.append(" and flux2.operateur=" ).append(pIdOperateur);
		request.append(" and flux2.campagne=").append( pIdCampagne ).append(" )" );
		//request.append(" order by cl.nom asc" );
		mLog.debug( "requete =  " + request.toString() );
		Query query = this.getSession().createQuery( request.toString() );
		List sites = query.list();
		if(sites != null && sites.size()>0 && sites.isEmpty() == false){
			listSites = (ArrayList) sites;
			mLog.debug("nb sites de consommation = " + listSites.size() );
		}
		return listSites;
	}
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
/** 
        *
        * <!-- begin-xdoclet-definition --> 
        * @throws IOException 
        * @ejb.interface-method view-type="remote"
        * @ejb.transaction type="Required" 
        * <!-- end-xdoclet-definition --> 
        * @generated
        *
        * //TODO: Must provide implementation for bean method stub
        */
	public ArrayList loadSiteConsommation( Long pIdCampagne, Long pIdClient, Long pIdOperateur ){
		try{
			ArrayList lSiteConsommations = null;
			mLogService.debug("loadSiteConsommation on");
			ISiteConsommationDao siteConsommationDaoInterface = (ISiteConsommationDao) StaticSpringApplicationContext.getDao("SiteConsommationDao");
			lSiteConsommations = siteConsommationDaoInterface.loadSiteConsommation(pIdCampagne, pIdClient, pIdOperateur);
			mLogService.debug("loadSiteConsommation off");
			return( lSiteConsommations );
		}catch (Exception e) {
			throw ExceptionManagement.exceptionManagement(e);
		}
	}
Voilà les traces :

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
[com.gdf.sialloc.collecte.ejb.GestionSiteConsommation_e0qa8m_Impl] 17/11/2009 13:55:58 DEBUG : loadSiteConsommation on
[com.gdf.sialloc.dao.StaticSpringApplicationContext] 17/11/2009 13:55:58 DEBUG : getDao SiteConsommationDao
[org.springframework.beans.factory.support.DefaultListableBeanFactory] 17/11/2009 13:55:58 DEBUG : Returning cached instance of singleton bean 'SiteConsommationDao'
[com.gdf.sialloc.collecte.dao.impl.SiteConsommationDaoImpl] 17/11/2009 13:55:58 DEBUG : requete =  select site from Client as cl, SiteConsommation as site, Flux as flux, OperationObjet as lien, Operation as op  where op.id = lien.operation  and op.codeOperation = 'SIC1' and flux.id = lien.idObjet and lien.className = 'com.gdf.sialloc.referentiel.domain.Flux' and flux.campagne = 61 and flux.operateur = 3 and flux.validite = true and site.flux = flux.id and cl.id = site.client and op.dateCreation = ( select max( op2.dateCreation ) from Operation as op2 , OperationObjet as lien2 , Flux as flux2 where op2.codeOperation = 'SIC1' and op2.id = lien2.operation  and lien2.className= 'com.gdf.sialloc.referentiel.domain.Flux' and flux2.id = lien2.idObjet and flux2.validite = true and flux2.operateur=3 and flux2.campagne=61 )
[org.springframework.orm.hibernate3.SessionFactoryUtils] 17/11/2009 13:55:58 DEBUG : Opening Hibernate Session
[org.springframework.orm.hibernate3.SessionFactoryUtils] 17/11/2009 13:55:58 DEBUG : Registering JTA transaction synchronization for new Hibernate Session
[org.springframework.transaction.support.TransactionSynchronizationManager] 17/11/2009 13:55:58 DEBUG : Bound value [org.springframework.orm.hibernate3.SessionHolder@1792ee4] for key [org.hibernate.impl.SessionFactoryImpl@512da4] to thread [ExecuteThread: '12' for queue: 'weblogic.kernel.Default']
[org.hibernate.SQL] 17/11/2009 13:55:58 DEBUG : select siteconsom1_.ID_SITE_CONSOMMATION as ID1_47_, siteconsom1_.version as version47_, siteconsom1_.DATECREATION as DATECREA3_47_, siteconsom1_.DATEMODIFICATION as DATEMODI4_47_, siteconsom1_.ID_UTILISATEUR as ID5_47_, siteconsom1_.CODE_POINT as CODE6_47_, siteconsom1_.ID_FLUX as ID7_47_, siteconsom1_.ID_ZONE as ID8_47_, siteconsom1_.ID_CLIENT as ID9_47_ from CLIENT client0_, SITE_CONSOMMATION siteconsom1_, FLUX flux2_, LIEN_OPERATION_OBJET operationo3_, OPERATION operation4_ where (operation4_.ID_OPERATION=operationo3_.ID_OPERATION )and(operation4_.CODE_OPERATION='SIC1' )and(flux2_.ID_FLUX=operationo3_.ID_OBJET )and(operationo3_.CLASS_NAME='com.gdf.sialloc.referentiel.domain.Flux' )and(flux2_.ID_CAMPAGNE=61 )and(flux2_.ID_OPERATEUR=3 )and(flux2_.VALIDITE=1 )and(siteconsom1_.ID_FLUX=flux2_.ID_FLUX )and(client0_.ID=siteconsom1_.ID_CLIENT )and(operation4_.DATECREATION=(select max(operation5_.DATECREATION) from OPERATION operation5_, LIEN_OPERATION_OBJET operationo6_, FLUX flux7_ where (operation5_.CODE_OPERATION='SIC1' )and(operation5_.ID_OPERATION=operationo6_.ID_OPERATION )and(operationo6_.CLASS_NAME='com.gdf.sialloc.referentiel.domain.Flux' )and(flux7_.ID_FLUX=operationo6_.ID_OBJET )and(flux7_.VALIDITE=1 )and(flux7_.ID_OPERATEUR=3 )and(flux7_.ID_CAMPAGNE=61 )))
[org.hibernate.SQL] 17/11/2009 13:55:58 DEBUG : select flux0_.ID_FLUX as ID1_20_4_, flux0_.version as version20_4_, flux0_.DATECREATION as DATECREA3_20_4_, flux0_.DATEMODIFICATION as DATEMODI4_20_4_, flux0_.ID_UTILISATEUR as ID5_20_4_, flux0_.DATE_INSERTION as DATE6_20_4_, flux0_.NOM_FLUX as NOM7_20_4_, flux0_.VALIDITE as VALIDITE20_4_, flux0_.CORRECT as CORRECT20_4_, flux0_.PUBLIE as PUBLIE20_4_, flux0_.MESSAGE_ERREUR as MESSAGE11_20_4_, flux0_.FLUX as FLUX20_4_, flux0_.ID_DESCRIPTEUR as ID13_20_4_, flux0_.ID_CAMPAGNE as ID14_20_4_, flux0_.ID_OPERATEUR as ID15_20_4_, descripteu1_.ID_DESCRIPTEUR_FLUX as ID1_19_0_, descripteu1_.version as version19_0_, descripteu1_.DATECREATION as DATECREA3_19_0_, descripteu1_.DATEMODIFICATION as DATEMODI4_19_0_, descripteu1_.ID_UTILISATEUR as ID5_19_0_, descripteu1_.NATURE as NATURE19_0_, descripteu1_.PATERN as PATERN19_0_, descripteu1_.ENTREESORTIE as ENTREESO8_19_0_, campagne2_.ID_CAMPAGNE as ID1_15_1_, campagne2_.version as version15_1_, campagne2_.DATECREATION as DATECREA3_15_1_, campagne2_.DATEMODIFICATION as DATEMODI4_15_1_, campagne2_.ID_UTILISATEUR as ID5_15_1_, campagne2_.LIBELLE_CAMPAGNE as LIBELLE6_15_1_, campagne2_.CODE_CAMPAGNE as CODE7_15_1_, campagne2_.DATEOUVERTURE as DATEOUVE8_15_1_, campagne2_.DATECLOTURE as DATECLOT9_15_1_, campagne2_.PROPOSITION_ALLOCATION as PROPOSI10_15_1_, campagne2_.SAISIE_DROITS_EXERCES as SAISIE11_15_1_, campagne2_.RENSEIGNEMENT_ETAPE7 as RENSEIG12_15_1_, campagne2_.ID_CAMPAGNE_PRECEDENT as ID13_15_1_, campagne3_.ID_CAMPAGNE as ID1_15_2_, campagne3_.version as version15_2_, campagne3_.DATECREATION as DATECREA3_15_2_, campagne3_.DATEMODIFICATION as DATEMODI4_15_2_, campagne3_.ID_UTILISATEUR as ID5_15_2_, campagne3_.LIBELLE_CAMPAGNE as LIBELLE6_15_2_, campagne3_.CODE_CAMPAGNE as CODE7_15_2_, campagne3_.DATEOUVERTURE as DATEOUVE8_15_2_, campagne3_.DATECLOTURE as DATECLOT9_15_2_, campagne3_.PROPOSITION_ALLOCATION as PROPOSI10_15_2_, campagne3_.SAISIE_DROITS_EXERCES as SAISIE11_15_2_, campagne3_.RENSEIGNEMENT_ETAPE7 as RENSEIG12_15_2_, campagne3_.ID_CAMPAGNE_PRECEDENT as ID13_15_2_, operateur4_.ID_OPERATEUR as ID1_22_3_, operateur4_.version as version22_3_, operateur4_.DATECREATION as DATECREA3_22_3_, operateur4_.DATEMODIFICATION as DATEMODI4_22_3_, operateur4_.ID_UTILISATEUR as ID5_22_3_, operateur4_.CODE_OPERATEUR as CODE6_22_3_, operateur4_.NOM_OPERATEUR as NOM7_22_3_, operateur4_.CODE_CLIENT_IMPORT as CODE8_22_3_, operateur4_.PREFIXE_CODE_POINT as PREFIXE9_22_3_ from FLUX flux0_ left outer join DESCRIPTEUR_FLUX descripteu1_ on flux0_.ID_DESCRIPTEUR=descripteu1_.ID_DESCRIPTEUR_FLUX left outer join CAMPAGNE campagne2_ on flux0_.ID_CAMPAGNE=campagne2_.ID_CAMPAGNE left outer join CAMPAGNE campagne3_ on campagne2_.ID_CAMPAGNE_PRECEDENT=campagne3_.ID_CAMPAGNE left outer join OPERATEUR operateur4_ on flux0_.ID_OPERATEUR=operateur4_.ID_OPERATEUR where flux0_.ID_FLUX=?
[org.hibernate.SQL] 17/11/2009 13:55:58 DEBUG : select zoneequili0_.ID_ZONE_EQUILIBRAGE as ID1_17_0_, zoneequili0_.version as version17_0_, zoneequili0_.DATECREATION as DATECREA3_17_0_, zoneequili0_.DATEMODIFICATION as DATEMODI4_17_0_, zoneequili0_.ID_UTILISATEUR as ID5_17_0_, zoneequili0_.LIBELLE_ZONE as LIBELLE6_17_0_, zoneequili0_.CODE_ZONE as CODE7_17_0_, zoneequili0_.ORDRE as ORDRE17_0_, zoneequili0_.DATE_DEBUT as DATE9_17_0_, zoneequili0_.DATE_FIN as DATE10_17_0_ from ZONE_EQUILIBRAGE zoneequili0_ where zoneequili0_.ID_ZONE_EQUILIBRAGE=?
[org.hibernate.SQL] 17/11/2009 13:55:58 DEBUG : select client0_.ID as ID14_0_, client0_.version as version14_0_, client0_.DATECREATION as DATECREA3_14_0_, client0_.DATEMODIFICATION as DATEMODI4_14_0_, client0_.NOM as NOM14_0_, client0_.CODE as CODE14_0_, client0_.CODEGRT as CODEGRT14_0_, client0_.CODEGRD as CODEGRD14_0_ from CLIENT client0_ where client0_.ID=?
[org.hibernate.SQL] 17/11/2009 13:55:58 DEBUG : select zoneequili0_.ID_ZONE_EQUILIBRAGE as ID1_17_0_, zoneequili0_.version as version17_0_, zoneequili0_.DATECREATION as DATECREA3_17_0_, zoneequili0_.DATEMODIFICATION as DATEMODI4_17_0_, zoneequili0_.ID_UTILISATEUR as ID5_17_0_, zoneequili0_.LIBELLE_ZONE as LIBELLE6_17_0_, zoneequili0_.CODE_ZONE as CODE7_17_0_, zoneequili0_.ORDRE as ORDRE17_0_, zoneequili0_.DATE_DEBUT as DATE9_17_0_, zoneequili0_.DATE_FIN as DATE10_17_0_ from ZONE_EQUILIBRAGE zoneequili0_ where zoneequili0_.ID_ZONE_EQUILIBRAGE=?
[org.hibernate.SQL] 17/11/2009 13:55:58 DEBUG : select client0_.ID as ID14_0_, client0_.version as version14_0_, client0_.DATECREATION as DATECREA3_14_0_, client0_.DATEMODIFICATION as DATEMODI4_14_0_, client0_.NOM as NOM14_0_, client0_.CODE as CODE14_0_, client0_.CODEGRT as CODEGRT14_0_, client0_.CODEGRD as CODEGRD14_0_ from CLIENT client0_ where client0_.ID=?
[org.hibernate.SQL] 17/11/2009 13:55:58 DEBUG : select zoneequili0_.ID_ZONE_EQUILIBRAGE as ID1_17_0_, zoneequili0_.version as version17_0_, zoneequili0_.DATECREATION as DATECREA3_17_0_, zoneequili0_.DATEMODIFICATION as DATEMODI4_17_0_, zoneequili0_.ID_UTILISATEUR as ID5_17_0_, zoneequili0_.LIBELLE_ZONE as LIBELLE6_17_0_, zoneequili0_.CODE_ZONE as CODE7_17_0_, zoneequili0_.ORDRE as ORDRE17_0_, zoneequili0_.DATE_DEBUT as DATE9_17_0_, zoneequili0_.DATE_FIN as DATE10_17_0_ from ZONE_EQUILIBRAGE zoneequili0_ where zoneequili0_.ID_ZONE_EQUILIBRAGE=?
[com.gdf.sialloc.collecte.dao.impl.SiteConsommationDaoImpl] 17/11/2009 13:55:58 DEBUG : nb sites de consommation = 4
[com.gdf.sialloc.collecte.ejb.GestionSiteConsommation_e0qa8m_Impl] 17/11/2009 13:55:58 DEBUG : loadSiteConsommation off
[org.springframework.orm.hibernate3.SessionFactoryUtils] 17/11/2009 13:55:58 DEBUG : Flushing Hibernate Session on transaction synchronization
[org.hibernate.SQL] 17/11/2009 13:55:58 DEBUG : update FLUX set version=?, DATEMODIFICATION=?, ID_UTILISATEUR=?, DATE_INSERTION=?, NOM_FLUX=?, VALIDITE=?, CORRECT=?, PUBLIE=?, FLUX=?, ID_DESCRIPTEUR=?, ID_CAMPAGNE=?, ID_OPERATEUR=? where ID_FLUX=? and version=?
[org.springframework.transaction.support.TransactionSynchronizationManager] 17/11/2009 13:55:58 DEBUG : Removed value [org.springframework.orm.hibernate3.SessionHolder@1792ee4] for key [org.hibernate.impl.SessionFactoryImpl@512da4] from thread [ExecuteThread: '12' for queue: 'weblogic.kernel.Default']
[org.springframework.orm.hibernate3.SessionFactoryUtils] 17/11/2009 13:55:58 DEBUG : Closing Hibernate Session