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 :

une expression dans une critere qui ne reconnait pas un parametre


Sujet :

Hibernate Java

  1. #1
    Membre du Club
    Inscrit en
    Mars 2006
    Messages
    45
    Détails du profil
    Informations personnelles :
    Âge : 41

    Informations forums :
    Inscription : Mars 2006
    Messages : 45
    Points : 43
    Points
    43
    Par défaut une expression dans une critere qui ne reconnait pas un parametre
    Bonjour,
    alors voila mon probleme, j'aimerai executer cette requete (avec critere)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    session.createCriteria(Service.class).
    add(Expression.and(Expression.eq(Service.PROP_ID,Role.PROP_ID), Expression.like(Role.PROP_LOGIN, login)))
    mais ca e donne l'exception suivante

    org.hibernate.QueryException: could not resolve property: Login of: com.proxymit.ihmedb.mapping.Service

    sachant que login est un String

  2. #2
    Modérateur
    Avatar de OButterlin
    Homme Profil pro
    Inscrit en
    Novembre 2006
    Messages
    7 313
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 7 313
    Points : 9 529
    Points
    9 529
    Billets dans le blog
    1
    Par défaut
    - login est une propriété de Service.class ?
    - le getter est getLogin() ?

  3. #3
    Membre du Club
    Inscrit en
    Mars 2006
    Messages
    45
    Détails du profil
    Informations personnelles :
    Âge : 41

    Informations forums :
    Inscription : Mars 2006
    Messages : 45
    Points : 43
    Points
    43
    Par défaut
    non login est une variable qui a eu sa valeur avec un
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    String login=(String)request.getSession().getAttribut("user");

  4. #4
    Modérateur
    Avatar de OButterlin
    Homme Profil pro
    Inscrit en
    Novembre 2006
    Messages
    7 313
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 7 313
    Points : 9 529
    Points
    9 529
    Billets dans le blog
    1
    Par défaut
    Quand tu fais l'Expression, login n'est pas null ?

  5. #5
    Membre du Club
    Inscrit en
    Mars 2006
    Messages
    45
    Détails du profil
    Informations personnelles :
    Âge : 41

    Informations forums :
    Inscription : Mars 2006
    Messages : 45
    Points : 43
    Points
    43
    Par défaut
    non j'ai verifié. login n'est pas null

  6. #6
    Modérateur
    Avatar de OButterlin
    Homme Profil pro
    Inscrit en
    Novembre 2006
    Messages
    7 313
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 7 313
    Points : 9 529
    Points
    9 529
    Billets dans le blog
    1
    Par défaut
    On peut voir le code de com.proxymit.ihmedb.mapping.Service ?

    Le message fait référence à une propriété Login de cette classe, si ça se trouve, le problème ne vient pas du paramètre "login"

    A+

  7. #7
    Membre du Club
    Inscrit en
    Mars 2006
    Messages
    45
    Détails du profil
    Informations personnelles :
    Âge : 41

    Informations forums :
    Inscription : Mars 2006
    Messages : 45
    Points : 43
    Points
    43
    Par défaut
    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
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    public abstract class BaseService  implements Serializable {
     
    	public static String REF = "Service";
    	public static String PROP_EXT_EVENT_NODE = "ExtEventNode";
    	public static String PROP_END_OF_CALL_NODE = "EndOfCallNode";
    	public static String PROP_SERVICE_VERSION = "ServiceVersion";
    	public static String PROP_ERROR_NODE = "ErrorNode";
    	public static String PROP_SERVICE_NAME = "ServiceName";
    	public static String PROP_START_OF_CALL_NODE = "StartOfCallNode";
    	public static String PROP_ID = "Id";
     
     
    	// constructors
    	public BaseService () {
    		initialize();
    	}
     
    	/**
             * Constructor for primary key
             */
    	public BaseService (java.lang.Integer id) {
    		this.setId(id);
    		initialize();
    	}
     
    	protected void initialize () {}
     
     
     
    	private int hashCode = Integer.MIN_VALUE;
     
    	// primary key
    	private java.lang.Integer id;
     
    	// fields
    	private java.lang.Integer endOfCallNode;
    	private java.lang.Integer errorNode;
    	private java.lang.Integer extEventNode;
    	private java.lang.String serviceName;
    	private java.lang.String serviceVersion;
    	private java.lang.Integer startOfCallNode;
     
    	// collections
    	private java.util.Set<com.proxymit.ihmedb.mapping.Configelets> configelets;
    	private java.util.Set<com.proxymit.ihmedb.mapping.Environnement> environnements;
    	private java.util.Set<com.proxymit.ihmedb.mapping.Globalvars> globalvars;
    	private java.util.Set<com.proxymit.ihmedb.mapping.Nodeinstance> nodeinstances;
    	private java.util.Set<com.proxymit.ihmedb.mapping.Promptlist> promptlists;
    	private java.util.Set<com.proxymit.ihmedb.mapping.Props> props;
    	private java.util.Set<com.proxymit.ihmedb.mapping.Role> roles;
    	private java.util.Set<com.proxymit.ihmedb.mapping.Stats> stats;
     
     
     
    	/**
             * Return the unique identifier of this class
         * @hibernate.id
         *  generator-class="increment"
         *  column="idService"
         */
    	public java.lang.Integer getId () {
    		return id;
    	}
     
    	/**
             * Set the unique identifier of this class
             * @param id the new ID
             */
    	public void setId (java.lang.Integer id) {
    		this.id = id;
    		this.hashCode = Integer.MIN_VALUE;
    	}
     
     
     
     
    	/**
             * Return the value associated with the column: endOfCallNode
             */
    	public java.lang.Integer getEndOfCallNode () {
    		return endOfCallNode;
    	}
     
    	/**
             * Set the value related to the column: endOfCallNode
             * @param endOfCallNode the endOfCallNode value
             */
    	public void setEndOfCallNode (java.lang.Integer endOfCallNode) {
    		this.endOfCallNode = endOfCallNode;
    	}
     
     
     
    	/**
             * Return the value associated with the column: errorNode
             */
    	public java.lang.Integer getErrorNode () {
    		return errorNode;
    	}
     
    	/**
             * Set the value related to the column: errorNode
             * @param errorNode the errorNode value
             */
    	public void setErrorNode (java.lang.Integer errorNode) {
    		this.errorNode = errorNode;
    	}
     
     
     
    	/**
             * Return the value associated with the column: extEventNode
             */
    	public java.lang.Integer getExtEventNode () {
    		return extEventNode;
    	}
     
    	/**
             * Set the value related to the column: extEventNode
             * @param extEventNode the extEventNode value
             */
    	public void setExtEventNode (java.lang.Integer extEventNode) {
    		this.extEventNode = extEventNode;
    	}
     
     
     
    	/**
             * Return the value associated with the column: serviceName
             */
    	public java.lang.String getServiceName () {
    		return serviceName;
    	}
     
    	/**
             * Set the value related to the column: serviceName
             * @param serviceName the serviceName value
             */
    	public void setServiceName (java.lang.String serviceName) {
    		this.serviceName = serviceName;
    	}
     
     
     
    	/**
             * Return the value associated with the column: serviceVersion
             */
    	public java.lang.String getServiceVersion () {
    		return serviceVersion;
    	}
     
    	/**
             * Set the value related to the column: serviceVersion
             * @param serviceVersion the serviceVersion value
             */
    	public void setServiceVersion (java.lang.String serviceVersion) {
    		this.serviceVersion = serviceVersion;
    	}
     
     
     
    	/**
             * Return the value associated with the column: startOfCallNode
             */
    	public java.lang.Integer getStartOfCallNode () {
    		return startOfCallNode;
    	}
     
    	/**
             * Set the value related to the column: startOfCallNode
             * @param startOfCallNode the startOfCallNode value
             */
    	public void setStartOfCallNode (java.lang.Integer startOfCallNode) {
    		this.startOfCallNode = startOfCallNode;
    	}
     
     
     
    	/**
             * Return the value associated with the column: Configelets
             */
    	public java.util.Set<com.proxymit.ihmedb.mapping.Configelets> getConfigelets () {
    		return configelets;
    	}
     
    	/**
             * Set the value related to the column: Configelets
             * @param configelets the Configelets value
             */
    	public void setConfigelets (java.util.Set<com.proxymit.ihmedb.mapping.Configelets> configelets) {
    		this.configelets = configelets;
    	}
     
    	public void addToConfigelets (com.proxymit.ihmedb.mapping.Configelets configelets) {
    		if (null == getConfigelets()) setConfigelets(new java.util.TreeSet<com.proxymit.ihmedb.mapping.Configelets>());
    		getConfigelets().add(configelets);
    	}
     
     
     
    	/**
             * Return the value associated with the column: Environnements
             */
    	public java.util.Set<com.proxymit.ihmedb.mapping.Environnement> getEnvironnements () {
    		return environnements;
    	}
     
    	/**
             * Set the value related to the column: Environnements
             * @param environnements the Environnements value
             */
    	public void setEnvironnements (java.util.Set<com.proxymit.ihmedb.mapping.Environnement> environnements) {
    		this.environnements = environnements;
    	}
     
    	public void addToEnvironnements (com.proxymit.ihmedb.mapping.Environnement environnement) {
    		if (null == getEnvironnements()) setEnvironnements(new java.util.TreeSet<com.proxymit.ihmedb.mapping.Environnement>());
    		getEnvironnements().add(environnement);
    	}
     
     
     
    	/**
             * Return the value associated with the column: Globalvars
             */
    	public java.util.Set<com.proxymit.ihmedb.mapping.Globalvars> getGlobalvars () {
    		return globalvars;
    	}
     
    	/**
             * Set the value related to the column: Globalvars
             * @param globalvars the Globalvars value
             */
    	public void setGlobalvars (java.util.Set<com.proxymit.ihmedb.mapping.Globalvars> globalvars) {
    		this.globalvars = globalvars;
    	}
     
    	public void addToGlobalvars (com.proxymit.ihmedb.mapping.Globalvars globalvars) {
    		if (null == getGlobalvars()) setGlobalvars(new java.util.TreeSet<com.proxymit.ihmedb.mapping.Globalvars>());
    		getGlobalvars().add(globalvars);
    	}
     
     
     
    	/**
             * Return the value associated with the column: Nodeinstances
             */
    	public java.util.Set<com.proxymit.ihmedb.mapping.Nodeinstance> getNodeinstances () {
    		return nodeinstances;
    	}
     
    	/**
             * Set the value related to the column: Nodeinstances
             * @param nodeinstances the Nodeinstances value
             */
    	public void setNodeinstances (java.util.Set<com.proxymit.ihmedb.mapping.Nodeinstance> nodeinstances) {
    		this.nodeinstances = nodeinstances;
    	}
     
    	public void addToNodeinstances (com.proxymit.ihmedb.mapping.Nodeinstance nodeinstance) {
    		if (null == getNodeinstances()) setNodeinstances(new java.util.TreeSet<com.proxymit.ihmedb.mapping.Nodeinstance>());
    		getNodeinstances().add(nodeinstance);
    	}
     
     
     
    	/**
             * Return the value associated with the column: Promptlists
             */
    	public java.util.Set<com.proxymit.ihmedb.mapping.Promptlist> getPromptlists () {
    		return promptlists;
    	}
     
    	/**
             * Set the value related to the column: Promptlists
             * @param promptlists the Promptlists value
             */
    	public void setPromptlists (java.util.Set<com.proxymit.ihmedb.mapping.Promptlist> promptlists) {
    		this.promptlists = promptlists;
    	}
     
    	public void addToPromptlists (com.proxymit.ihmedb.mapping.Promptlist promptlist) {
    		if (null == getPromptlists()) setPromptlists(new java.util.TreeSet<com.proxymit.ihmedb.mapping.Promptlist>());
    		getPromptlists().add(promptlist);
    	}
     
     
     
    	/**
             * Return the value associated with the column: Props
             */
    	public java.util.Set<com.proxymit.ihmedb.mapping.Props> getProps () {
    		return props;
    	}
     
    	/**
             * Set the value related to the column: Props
             * @param props the Props value
             */
    	public void setProps (java.util.Set<com.proxymit.ihmedb.mapping.Props> props) {
    		this.props = props;
    	}
     
    	public void addToProps (com.proxymit.ihmedb.mapping.Props props) {
    		if (null == getProps()) setProps(new java.util.TreeSet<com.proxymit.ihmedb.mapping.Props>());
    		getProps().add(props);
    	}
     
     
     
    	/**
             * Return the value associated with the column: Roles
             */
    	public java.util.Set<com.proxymit.ihmedb.mapping.Role> getRoles () {
    		return roles;
    	}
     
    	/**
             * Set the value related to the column: Roles
             * @param roles the Roles value
             */
    	public void setRoles (java.util.Set<com.proxymit.ihmedb.mapping.Role> roles) {
    		this.roles = roles;
    	}
     
    	public void addToRoles (com.proxymit.ihmedb.mapping.Role role) {
    		if (null == getRoles()) setRoles(new java.util.TreeSet<com.proxymit.ihmedb.mapping.Role>());
    		getRoles().add(role);
    	}
     
     
     
    	/**
             * Return the value associated with the column: Stats
             */
    	public java.util.Set<com.proxymit.ihmedb.mapping.Stats> getStats () {
    		return stats;
    	}
     
    	/**
             * Set the value related to the column: Stats
             * @param stats the Stats value
             */
    	public void setStats (java.util.Set<com.proxymit.ihmedb.mapping.Stats> stats) {
    		this.stats = stats;
    	}
     
    	public void addToStats (com.proxymit.ihmedb.mapping.Stats stats) {
    		if (null == getStats()) setStats(new java.util.TreeSet<com.proxymit.ihmedb.mapping.Stats>());
    		getStats().add(stats);
    	}
     
     
     
     
    	public boolean equals (Object obj) {
    		if (null == obj) return false;
    		if (!(obj instanceof com.proxymit.ihmedb.mapping.Service)) return false;
    		else {
    			com.proxymit.ihmedb.mapping.Service service = (com.proxymit.ihmedb.mapping.Service) obj;
    			if (null == this.getId() || null == service.getId()) return false;
    			else return (this.getId().equals(service.getId()));
    		}
    	}
     
    	public int hashCode () {
    		if (Integer.MIN_VALUE == this.hashCode) {
    			if (null == this.getId()) return super.hashCode();
    			else {
    				String hashStr = this.getClass().getName() + ":" + this.getId().hashCode();
    				this.hashCode = hashStr.hashCode();
    			}
    		}
    		return this.hashCode;
    	}
     
     
    	public String toString () {
    		return super.toString();
    	}
     
     
    }
    la classe Service herite de cette classe et ne contient qu'un constructeur.

    Sinon je reformule mon pb
    J'ai deux tables liées avec une association un a plusieurs

    * les deux tables sont "Service" et "Role"
    * un service a plusieurs roles
    * la table role a un attribut "login"

    j'aimerai afficher (avec des criteres) les enregistrements de service dont la valeur login dans la table role est egale a une valeur donnée.

  8. #8
    Modérateur
    Avatar de OButterlin
    Homme Profil pro
    Inscrit en
    Novembre 2006
    Messages
    7 313
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 7 313
    Points : 9 529
    Points
    9 529
    Billets dans le blog
    1
    Par défaut
    Je ferais un truc comme ça, je te laisse adapter :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
    s = HibernateUtil.currentSession();
    SQLQuery query = s.createSQLQuery("select * from Al_Utilisateur where uti_nom in (select uti_nom from al_utilisateur_info where uti_libelle like 'p73%')").addEntity(AlUtilisateur.class);
    Iterator it = query.list().iterator();
    while ( it.hasNext() )
    {
       System.out.println("Utilisateur : " + ((AlUtilisateur)it.next()).getUtiNom());
    }

  9. #9
    Membre du Club
    Inscrit en
    Mars 2006
    Messages
    45
    Détails du profil
    Informations personnelles :
    Âge : 41

    Informations forums :
    Inscription : Mars 2006
    Messages : 45
    Points : 43
    Points
    43
    Par défaut
    Bonjour,
    Merci pour la solution mais j'ai resolu le pb d'une autre maniere
    En effet j'ai jeté un coup d'oeil sur la classe Role et ily a une methode qui renvoit l'id du service (getIdService). En realite cette methode me renvoit l'objet tout entier donc je peux le manipuler
    En tt cas merci pour ton aide.

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

Discussions similaires

  1. [XL-2007] Afficher une checkbox dans une feuille si une checkbox d'une autre feuille est cochée
    Par JessieCoutas dans le forum Macros et VBA Excel
    Réponses: 3
    Dernier message: 18/08/2009, 13h35
  2. portée d'une variable dans une fonction dans une méthode
    Par laurentg2003 dans le forum Général JavaScript
    Réponses: 4
    Dernier message: 29/06/2009, 19h05
  3. [POO] dans une classe, appeler une fonction dans une méthode
    Par arnaudperfect dans le forum Langage
    Réponses: 3
    Dernier message: 26/08/2007, 23h04
  4. Envoyer une formulaire dans une page dans une Frame
    Par zooffy dans le forum Balisage (X)HTML et validation W3C
    Réponses: 5
    Dernier message: 29/06/2007, 10h13
  5. Recherche une valeur d'une cellule dans une colonne d'une autre feuille
    Par kourria dans le forum Macros et VBA Excel
    Réponses: 8
    Dernier message: 21/06/2007, 13h48

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