IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Hibernate Java Discussion :

probleme avec update


Sujet :

Hibernate Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Inscrit en
    Mai 2002
    Messages
    219
    Détails du profil
    Informations forums :
    Inscription : Mai 2002
    Messages : 219
    Par défaut probleme avec update
    bonjour tout le monde
    j execute un update qui ne se fait pas
    voici le hbm
    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
     
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC
    	"-//Hibernate/Hibernate Mapping DTD//EN"
    	"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
     
    <hibernate-mapping package="pojo">
    	<class 
    		name="InfogenePojo"
    		table="INFOGENE"
    		lazy="false"
    	>
     
    	<composite-id name="id" class="InfogeneId">
     
            <key-property name="noGroupe" column="IG_NO_GROUPE" type="string" length="6"/>
            <key-property name="noCertificat" column="IG_NO_CERTIFICAT" type="string"  length="10"/>
            <key-property name="dtEvenement" column="IG_DT_EVENEMENT" type="integer" length="8"/>
            <key-property name="noDossier" column="IG_NO_DOSSIER" type="string" length="6"/>
          </composite-id>
     
    		<property
    			name="doubleAss"
    			column="IG_ID_DOUBLE_ASS"
    			type="string"
    			not-null="false"
    			length="1"
    			lazy="false"
    		/>
     
    		<property
    			name="groupeClient"
    			column="IG_GROUPE_CLIENT"
    			type="string"
    			not-null="false"
    			length="8"
    			lazy="false"
    		/>
    		<property
    			name="noCertificatSam"
    			column="IG_NO_CERTIFICAT_SAM"
    			type="string"
    			not-null="false"
    			length="20"
    			lazy="false"
    		/>
     
     
    		<property
    			name="idUser"
    			column="IG_ID_USER"
    			type="string"
    			not-null="false"
    			length="4"
    			lazy="false"
    		/>
    		<property
    			name="dtModif"
    			column="IG_DT_MODIF"
    			type="integer"
    			not-null="false"
    			length="8"
    			lazy="false"
    		/>
    		<property
    			name="idAccident"
    			column="IG_ID_ACCIDENT"
    			type="string"
    			not-null="false"
    			length="1"
    			lazy="false"
    		/>
     
     
    </class>
    </hibernate-mapping>
    le pojo
    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
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
     
    package pojo;
     
    import java.io.Serializable;
     
    public class InfogeneId implements Serializable {
    	/**
             * 
             */
    	private static final long serialVersionUID = -5624859234341440063L;
     
    	private Integer dtEvenement;
     
    	private String noDossier;
     
    	private String noCertificat;
     
    	private String noGroupe;
     
    	public static long getSerialVersionUID() {
    		return serialVersionUID;
    	}
     
    	public Integer getDtEvenement() {
    		return dtEvenement;
    	}
     
    	public void setDtEvenement(final Integer dtEvenement) {
    		this.dtEvenement = dtEvenement;
    	}
     
    	public String getNoCertificat() {
    		return noCertificat;
    	}
     
    	public void setNoCertificat(final String noCertificat) {
    		this.noCertificat = noCertificat.trim();
    	}
     
    	public String getNoDossier() {
    		return noDossier;
    	}
     
    	public void setNoDossier(final String noDossier) {
    		this.noDossier = noDossier;
    	}
     
    	public String getNoGroupe() {
    		return noGroupe;
    	}
     
    	public void setNoGroupe(final String noGroupe) {
    		this.noGroupe = noGroupe;
    	}
     
    	@Override
    	public int hashCode() {
    		final int PRIME = 31;
    		int result = 1;
    		result = PRIME * result
    				+ ((noCertificat == null) ? 0 : noCertificat.hashCode());
    		result = PRIME * result
    				+ ((noDossier == null) ? 0 : noDossier.hashCode());
    		result = PRIME * result
    				+ ((noGroupe == null) ? 0 : noGroupe.hashCode());
    		return result;
    	}
     
    	@Override
    	public boolean equals(final Object obj) {
    		if (this == obj) {
    			return true;
    		}
    		if (obj == null) {
    			return false;
    		}
    		if (getClass() != obj.getClass()) {
    			return false;
    		}
    		final InfogeneId other = (InfogeneId) obj;
     
    		if (noCertificat == null) {
    			if (other.noCertificat != null) {
    				return false;
    			}
    		} else if (!noCertificat.equals(other.noCertificat)) {
    			return false;
    		}
    		if (noDossier == null) {
    			if (other.noDossier != null) {
    				return false;
    			}
    		} else if (!noDossier.equals(other.noDossier)) {
    			return false;
    		}
    		if (noGroupe == null) {
    			if (other.noGroupe != null) {
    				return false;
    			}
    		} else if (!noGroupe.equals(other.noGroupe)) {
    			return false;
    		}
    		return true;
    	}
     
    }
     
    package pojo;
     
    import java.io.Serializable;
     
    import InfogeneDAO;
     
    /**
     * This class has been automatically generated by Hibernate Synchronizer. For
     * more information or documentation, visit The Hibernate Synchronizer page at
     * http://www.binamics.com/hibernatesync or contact Joe Hudson at
     * joe@binamics.com.
     * 
     * This is an object that contains data related to the AVINFOGE table. Do not
     * modify this class because it will be overwritten if the configuration file
     * related to this class is modified.
     * 
     * @hibernate.class table="AVINFOGE"
     */
    public class InfogenePojo implements Serializable, InterfacePojo {
     
    	/**
             * 
             */
    	private static final long serialVersionUID = -2444185467393453780L;
     
    	// fields
    	private String doubleAss;
     
    	private String groupeClient;
     
    	private String noCertificatSam;
     
    	private String idUser = "STAR";
     
    	private Integer dtModif;
     
    	private String idAccident;
     
    	private InfogeneId id;
     
    	private InfogeneDAO dao;
     
    	private boolean persister = false;
     
    	public boolean isPersister() {
    		return persister;
    	}
     
    	public void setPersister(boolean persister) {
    		this.persister = persister;
    	}
     
    	// constructors
    	public InfogenePojo(final String doubleAss, final Integer dtEvenement,
    			final String groupeClient, final String noDossier,
    			final String noCertificatSam, final String noCertificat,
    			final String noGroupe, final String idUser, final Integer dtModif,
    			final String idAccident) {
    		final InfogeneId infogeneId = new InfogeneId();
    		infogeneId.setDtEvenement(dtEvenement);
    		infogeneId.setNoCertificat(noCertificat.trim());
    		infogeneId.setNoDossier(noDossier);
    		infogeneId.setNoGroupe(noGroupe);
    		this.setDoubleAss(doubleAss);
     
    		this.setGroupeClient(groupeClient);
    		this.setNoCertificatSam(noCertificatSam);
    		this.setIdUser(idUser);
    		this.setDtModif(dtModif);
    		this.setIdAccident(idAccident);
    		this.setId(infogeneId);
     
    	}
     
    	public InfogenePojo() {
    		initialize();
    	}
     
    	protected void initialize() {
    	}
     
    	public static long getSerialVersionUID() {
    		return serialVersionUID;
    	}
     
    	public String getDoubleAss() {
    		return doubleAss;
    	}
     
    	public void setDoubleAss(final String doubleAss) {
    		this.doubleAss = doubleAss;
    	}
     
    	public Integer getDtModif() {
    		return dtModif;
    	}
     
    	public void setDtModif(final Integer dtModif) {
    		this.dtModif = dtModif;
    	}
     
    	public String getGroupeClient() {
    		return groupeClient;
    	}
     
    	public void setGroupeClient(final String groupeClient) {
    		this.groupeClient = groupeClient;
    	}
     
    	public InfogeneId getId() {
    		return this.id;
    	}
     
    	public void setId(final InfogeneId id) {
    		this.id = id;
    	}
     
    	public String getIdAccident() {
    		return idAccident;
    	}
     
    	public void setIdAccident(final String idAccident) {
    		this.idAccident = idAccident;
    	}
     
    	public String getIdUser() {
    		return idUser;
    	}
     
    	public void setIdUser(final String idUser) {
    		this.idUser = idUser;
    	}
     
    	public String getNoCertificatSam() {
    		return noCertificatSam;
    	}
     
    	public void setNoCertificatSam(final String noCertificatSam) {
    		this.noCertificatSam = noCertificatSam;
    	}
     
    	/*
    	 * public boolean estDansLaBase(String cleDossier) throws HibernateException {
    	 * if (xc4dvoyDao == null) this.setDao(new InfogeneDAO()); List l =
    	 * this.getDao().find(cleDossier); if (l != null) return true; return false; }
    	 */
     
    	public InfogeneDAO getDao() {
    		return dao;
    	}
     
    	public void setDao(final InfogeneDAO dao) {
    		this.dao = dao;
    	}
     
    	@Override
    	public int hashCode() {
    		final int PRIME = 31;
    		int result = 1;
    		result = PRIME * result
    				+ ((doubleAss == null) ? 0 : doubleAss.hashCode());
     
    		result = PRIME * result + ((dtModif == null) ? 0 : dtModif.hashCode());
    		result = PRIME * result
    				+ ((groupeClient == null) ? 0 : groupeClient.hashCode());
    		result = PRIME * result + ((id == null) ? 0 : id.hashCode());
    		result = PRIME * result
    				+ ((idAccident == null) ? 0 : idAccident.hashCode());
    		result = PRIME * result + ((idUser == null) ? 0 : idUser.hashCode());
     
    		result = PRIME * result
    				+ ((noCertificatSam == null) ? 0 : noCertificatSam.hashCode());
     
    		return result;
    	}
     
    	@Override
    	public boolean equals(final Object obj) {
    		if (this == obj) {
    			return true;
    		}
    		if (obj == null) {
    			return false;
    		}
    		if (getClass() != obj.getClass()) {
    			return false;
    		}
    		final InfogenePojo other = (InfogenePojo) obj;
    		if (dao == null) {
    			if (other.dao != null) {
    				return false;
    			}
    		} else if (!dao.equals(other.dao)) {
    			return false;
    		}
    		if (doubleAss == null) {
    			if (other.doubleAss != null) {
    				return false;
    			}
    		} else if (!doubleAss.equals(other.doubleAss)) {
    			return false;
    		}
     
    		if (dtModif == null) {
    			if (other.dtModif != null) {
    				return false;
    			}
    		} else if (!dtModif.equals(other.dtModif)) {
    			return false;
    		}
    		if (groupeClient == null) {
    			if (other.groupeClient != null) {
    				return false;
    			}
    		} else if (!groupeClient.equals(other.groupeClient)) {
    			return false;
    		}
    		if (id == null) {
    			if (other.id != null) {
    				return false;
    			}
    		} else if (!id.equals(other.id)) {
    			return false;
    		}
    		if (idAccident == null) {
    			if (other.idAccident != null) {
    				return false;
    			}
    		} else if (!idAccident.equals(other.idAccident)) {
    			return false;
    		}
    		if (idUser == null) {
    			if (other.idUser != null) {
    				return false;
    			}
    		} else if (!idUser.equals(other.idUser)) {
    			return false;
    		}
     
    		if (noCertificatSam == null) {
    			if (other.noCertificatSam != null) {
    				return false;
    			}
    		} else if (!noCertificatSam.equals(other.noCertificatSam)) {
    			return false;
    		}
     
    		return true;
    	}
     
    	public void setId(Object id) {
    		this.id = (InfogeneId) id;
     
    	}
     
    }
    et mon code update
    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
     
    public void traite(final List<InfogenePojo> liste)
    			throws HibernateException {
    		logger
    				.info("debut de la methode traite de la classe"
    						+ this.getClass());
    		Session session = null;
    		try {
    			int i = 0;
    			for (final InfogenePojo element : liste) {
     
    				session = HibernateUtil.getSessionFactory().getCurrentSession();
    				session.beginTransaction();
     
    				if (element.isPersister()) {
     
    					session.update(element);
    				} else {
     
    					session.save(element);
     
    				}
    				if (i % 20 == 0) {
    					session.flush();
    					session.clear();
    				}
    				i++;
     
    			}
    			session.getTransaction().commit();
    		} catch (final HibernateException e) {
    			HibernateUtil.getSessionFactory().getCurrentSession()
    					.getTransaction().rollback();
    			setCodeRetour(8);
    			logger
    					.error("Erreur dans l'ecriture des donnees de la table Infogene");
    			throw new ServiceException(e.getMessage(), e);
     
    		} finally {
     
    			HibernateUtil.getSessionFactory().close();
     
    		}
    	}
    l ancienne date qui est 2006/10/10 reste
    elle ne change pas
    j avoue ne pas comprendre

  2. #2
    Membre éclairé
    Inscrit en
    Mai 2002
    Messages
    219
    Détails du profil
    Informations forums :
    Inscription : Mai 2002
    Messages : 219
    Par défaut RESOLU
    ok dsl tout le monde fausse alert
    c etait la db qui contenant un espace blanc a la fin .

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [SQL] Probleme avec UPDATE
    Par pierrot10 dans le forum PHP & Base de données
    Réponses: 2
    Dernier message: 01/10/2007, 11h42
  2. Probleme avec Update
    Par Tigre_82 dans le forum VB.NET
    Réponses: 1
    Dernier message: 06/09/2007, 15h20
  3. Probleme avec UPDATE
    Par xavier1936 dans le forum SQLite
    Réponses: 2
    Dernier message: 26/07/2007, 16h04
  4. [VBA-SQL]Probleme avec UPDATE
    Par omegabahamut dans le forum Access
    Réponses: 3
    Dernier message: 01/01/2007, 19h54
  5. Probleme avec UPDATE et INSERT INTO
    Par cmoimeme dans le forum Bases de données
    Réponses: 3
    Dernier message: 08/05/2006, 22h12

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo