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 :

Annotation et set


Sujet :

Hibernate Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Inactif  
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    2 189
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : Suisse

    Informations forums :
    Inscription : Mai 2006
    Messages : 2 189
    Par défaut Annotation et set
    Hello,

    J'ai créer la classe suivante

    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
     
    package com.ibm.arpa.model;
     
    import java.io.Serializable;
    import java.util.Set;
     
    import javax.persistence.CascadeType;
    import javax.persistence.Column;
    import javax.persistence.DiscriminatorValue;
    import javax.persistence.Entity;
    import javax.persistence.FetchType;
    import javax.persistence.ManyToMany;
    import javax.persistence.ManyToOne;
     
    import org.hibernate.annotations.Cascade;
     
    /**
     * Hibernate entity that define the Creancier table object
     * 
     * @author Alexandre Jaquet
     *
     */
    @Entity
    @DiscriminatorValue("CRE")
    public class Creancier extends Personne implements Serializable {
     
    	/** The serial version id. */
    	private static final long serialVersionUID = 0;
     
    	/** Type de rentier. */
    	@ManyToOne(fetch = FetchType.EAGER, optional = true)
    	@Cascade ((org.hibernate.annotations.CascadeType.SAVE_UPDATE))		
    	private TypeRentier rentier;
     
    	/** Other Type de rentier. */
    	@ManyToOne(fetch = FetchType.EAGER, optional = true)
    	@Cascade ((org.hibernate.annotations.CascadeType.SAVE_UPDATE))		
    	private AutresRente autresRente;
     
    	/** The autres revenues of the personne. */
    	@Column(name = "autresRevenus",nullable = true, length=20)	
    	private Integer autresRevenus;
     
    	/** Social institut. */
    	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, optional = true)	
    	private Adresse institutionSocial;
     
    	/** Representant legal. */
    	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, optional = true)	
    	private RepresentantLegal representantLegal;
     
    	/** Does our Creancier is marrié. */
    	@Column(name = "estRemarrie",nullable = true)
    	private Boolean estRemarrie;
     
    	/** The nouveau conjoint. */
    	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, optional = true)	
    	private Personne nouveauConjoint;
     
    	/** The number of childs. */
    	@Column(name = "nbrEnfantDansLeMenage",nullable = true, length=2)
    	private Integer nbrEnfantDansLeMenage;
     
    	/** The number of childs. */
    	@Column(name = "nbrAdulte",nullable = true, length=2)
    	private Integer nbrAdulteDansLeMenage;
     
    	/** The enfants at school. */
    	@ManyToMany(fetch = FetchType.EAGER)
    	@Cascade ((org.hibernate.annotations.CascadeType.SAVE_UPDATE))	
    	private Set<Personne> enfantsAuxEtudes;
     
    	/** The enfants at school. */
    	@ManyToMany(fetch = FetchType.EAGER)
    	@Cascade ((org.hibernate.annotations.CascadeType.SAVE_UPDATE))	
    	private Set<Personne> enfantsEnApprentissage;
     
    	/** Does our child are allowed to received subsides of formation ? */
    	private Boolean subsideDeFormation;
     
    	/** Does our child received rente AI ?*/
    	private Boolean enfantRecoitRenteAI;
     
    	/** The representant legal of the child other than Creancier. */
    	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, optional = true)	
    	private RepresentantLegal representantLegalEnfant;
     
    	/**
             * Constructor
             */
    	public Creancier() {
     
    	}
     
    	/**
             * Gets the type of rentier
             *  
             * @return TypeRentier returns the TypeRentier of the Creancier
             * 
             */
    	public TypeRentier getRentier() {
    		return rentier;
    	}
     
    	/**
             * Sets the TypeRentier of the Personne
             * 
             * @param rentier
             *                      The TypeRentier to set
             */
    	public void setRentier(TypeRentier rentier) {
    		this.rentier = rentier;
    	}
     
    	/**
             * Gets the AutresRente of the Personne
             * 
             * @return AutresRentes returns the AutresRente of the Personne
             */
    	public AutresRente getAutresRente() {
    		return autresRente;
    	}
     
    	/**
             * Sets the AutresRente of the Personne
             * 
             * @param autresRente
             *                      The AutresRente to set
             */
    	public void setAutresRente(AutresRente autresRente) {
    		this.autresRente = autresRente;
    	}
     
    	/**
             * Gets the amount of the autres revenues if any 
             * 
             * @return Integer returns the amount of the autres revenues
             */
    	public Integer getAutresRevenus() {
    		return autresRevenus;
    	}
     
    	/**
             * Sets the amount of the autres revenues
             * 
             * @param autresRevenus
             *                      The amount to set
             */
    	public void setAutresRevenus(Integer autresRevenus) {
    		this.autresRevenus = autresRevenus;
    	}
     
    	/**
             * Gets the Adresse of the institution social
             * 
             * @return Adresse returns the Adresse of the institution sociale 
             */
    	public Adresse getInstitutionSocial() {
    		return institutionSocial;
    	}
     
    	/**
             * Sets the Adresse of the institution sociale
             * 
             * @param institutionSocial
             *                      The Adresse to set
             */
    	public void setInstitutionSocial(Adresse institutionSocial) {
    		this.institutionSocial = institutionSocial;
    	}
     
    	/**
             * Gets the RepresentantLegal of the Creancier
             * @return
             */
    	public RepresentantLegal getRepresentantLegal() {
    		return representantLegal;
    	}
     
    	/**
             * Sets the RepresentantLegal of the Creancier
             * 
             * @param representantLegal
             *                      The representant legal to set
             */
    	public void setRepresentantLegal(RepresentantLegal representantLegal) {
    		this.representantLegal = representantLegal;
    	}
     
    	/**
             * Does our Creancier is remarrie ?
             * 
             * @return Boolean returns if the Creancier if remarrie 
             */
    	public Boolean getEstRemarrie() {
    		return estRemarrie;
    	}
     
    	/**
             * Set the boolean value for the estMarrie
             * 
             * @param estRemarrie
             *                      The boolean value to set
             */
    	public void setEstRemarrie(Boolean estRemarrie) {
    		this.estRemarrie = estRemarrie;
    	}
     
    	/**
             * Gets the nouveau conjoint of the Creancier
             * 
             * @return Personne returns the nouveau conjoint of the Creancier
             */
    	public Personne getNouveauConjoint() {
    		return nouveauConjoint;
    	}
     
    	/**
             * Set the nouveau conjoint of the Creancier
             * 
             * @param nouveauConjoint
             *                      The nouveau conjoint to set
             */
    	public void setNouveauConjoint(Personne nouveauConjoint) {
    		this.nouveauConjoint = nouveauConjoint;
    	}
     
    	/**
             * Gets the number of enfant dans le ménage
             * 
             * @return Integer returns the number of enfants dans le ménage
             */
    	public Integer getNbrEnfantDansLeMenage() {
    		return nbrEnfantDansLeMenage;
    	}
     
    	/**
             * Sets the number of enfants dans le ménage
             * 
             * @param nbrEnfantDansLeMenage
             *                      The nombre d'enfant dans le ménage to set
             */
    	public void setNbrEnfantDansLeMenage(Integer nbrEnfantDansLeMenage) {
    		this.nbrEnfantDansLeMenage = nbrEnfantDansLeMenage;
    	}
     
    	/**
             * Gets the nombre d'adulte dans le ménage
             * 
             * @return Integer returns the number of adulte dans le ménage
             */
    	public Integer getNbrAdulteDansLeMenage() {
    		return nbrAdulteDansLeMenage;
    	}
     
    	/**
             * Sets the number of adulte dans le ménage
             * 
             * @param nbrAdulteDansLeMenage
             *                      The nombre d'adulte dans le ménage
             */
    	public void setNbrAdulteDansLeMenage(Integer nbrAdulteDansLeMenage) {
    		this.nbrAdulteDansLeMenage = nbrAdulteDansLeMenage;
    	}
     
    	/**
             * Gets the list of enfants aux études
             * 
             * @return Set<Personne> returns the Set<Personne> of enfants aux études
             */
    	public Set<Personne> getEnfantsAuxEtudes() {
    		return enfantsAuxEtudes;
    	}
     
    	/**
             * Sets the collection of enfants aux études
             * 
             * @param enfantsAuxEtudes
             *                      The collections of enfants aux études to set
             */
    	public void setEnfantsAuxEtudes(Set<Personne> enfantsAuxEtudes) {
    		this.enfantsAuxEtudes = enfantsAuxEtudes;
    	}
     
    	/**
             * Gets the list of enfants en apprentissage
             * 
             * @return Set<Personne> returns the Set<Personne> of enfants en apprentissage
             */
     
    	public Set<Personne> getEnfantsEnApprentissage() {
    		return enfantsEnApprentissage;
    	}
     
    	/**
             * Sets the collection of enfants en apprentissage
             * 
             * @param enfantsAuxEtudes
             *                      The collections of enfants en apprentissage to set
             */
    	public void setEnfantsEnApprentissage(Set<Personne> enfantsEnApprentissage) {
    		this.enfantsEnApprentissage = enfantsEnApprentissage;
    	}
     
    	/**
             * Does our Creancier enfant have subside de formation
             * 
             * @return Boolean returns true if an enfant receive subside de formation
             */
    	public Boolean getSubsideDeFormation() {
    		return subsideDeFormation;
    	}
     
    	/**
             * Sets the boolean value for the subside de formation
             * 
             * @param subsideDeFormation
             *                      The boolean value to set
             */
    	public void setSubsideDeFormation(Boolean subsideDeFormation) {
    		this.subsideDeFormation = subsideDeFormation;
    	}
     
    	/**
             * Does one of our enfant receive a rente ai
             * 
             * @return Boolean returns true if an enfant receive a rente ai
             */
    	public Boolean getEnfantRecoitRenteAI() {
    		return enfantRecoitRenteAI;
    	}
     
    	/**
             * Sets the boolean value for enfantRecoitRenteAI
             * 
             * @param enfantRecoitRenteAI
             *                      The boolean value to set
             */
    	public void setEnfantRecoitRenteAI(Boolean enfantRecoitRenteAI) {
    		this.enfantRecoitRenteAI = enfantRecoitRenteAI;
    	}
     
    	/**
             * Gets the RepresentantLegal of the child if it's different than the Creancier
             * 
             * @return RepresentantLegal returns the RepresentantLegal of the enfant
             */
    	public RepresentantLegal getRepresentantLegalEnfant() {
    		return representantLegalEnfant;
    	}
     
    	/**
             * Sets the RepresentantLegal of the enfant
             * 
             * @param representantLegalEnfant
             *                      The representant legal to set
             */
    	public void setRepresentantLegalEnfant(RepresentantLegal representantLegalEnfant) {
    		this.representantLegalEnfant = representantLegalEnfant;
    	}
    }
    Dans cette classe j'ai deux attributs

    private Set<Personne> enfantsAuxEtudes;
    private Set<Personne> enfantsEnApprentissage;

    Lorsque hibernate créer les tables il ne créer que une seule association personne_personne

    j'aurais bien aimer qu'il me génère deux tables d'associations différentes

    es-ce possible ?

  2. #2
    Inactif  
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    2 189
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : Suisse

    Informations forums :
    Inscription : Mai 2006
    Messages : 2 189
    Par défaut
    une solution qui existe est de créer deux entitées différentes pour les deux types d enfants

    mais j aurais aimer savoir si une autre solution était possible

  3. #3
    Membre Expert
    Homme Profil pro
    Inscrit en
    Septembre 2006
    Messages
    2 963
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations forums :
    Inscription : Septembre 2006
    Messages : 2 963
    Par défaut
    Citation Envoyé par *alexandre* Voir le message
    une solution qui existe est de créer deux entitées différentes pour les deux types d enfants

    mais j aurais aimer savoir si une autre solution était possible
    voir @JoinTable

  4. #4
    Inactif  
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    2 189
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : Suisse

    Informations forums :
    Inscription : Mai 2006
    Messages : 2 189
    Par défaut
    merci je test ca demain

Discussions similaires

  1. set term ^
    Par tux dans le forum Débuter
    Réponses: 8
    Dernier message: 12/10/2004, 20h42
  2. Créer les get et set des classes
    Par cameleon2002 dans le forum JBuilder
    Réponses: 3
    Dernier message: 17/09/2003, 21h03
  3. IB 6.0.1 - Win XP - Character Set
    Par SuperTotor dans le forum InterBase
    Réponses: 4
    Dernier message: 03/06/2003, 20h25
  4. Query data set
    Par Sandra dans le forum JBuilder
    Réponses: 3
    Dernier message: 20/01/2003, 10h08
  5. character set // Nls_lang
    Par fopicht dans le forum Oracle
    Réponses: 2
    Dernier message: 23/05/2002, 12h04

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