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 :

No entity found for query qui marche par intermitance


Sujet :

Hibernate Java

  1. #1
    Membre averti Avatar de BakaOnigiri
    Inscrit en
    Avril 2002
    Messages
    366
    Détails du profil
    Informations forums :
    Inscription : Avril 2002
    Messages : 366
    Points : 437
    Points
    437
    Par défaut No entity found for query qui marche par intermitance
    Bonjour,

    j'ai un petit problème étrange :

    ce bout de code
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    public Journal getFromID(int id)
    	{
    		Query	q	= em.createNamedQuery("Journal.findFromId");
     
            System.out.println("--------------------- " + id);
    		q.setParameter("cID", id);
     
            Object t = q.getSingleResult();
            System.out.println(t);
    		return (Journal)t;
    	}
    me retourne un résultat valide si ID vaut 5 génère une exception javax.persistence.NoResultException: No entity found for query pour les valeurs 1, 2, 3, 4, 6 qui existent bien dans ma base.

    Le problème c'est que çà coince sur le cast du return, parceque le println fonctionne à chaque fois, j'ai bien un résultat qui s'affiche dans mes traces quelque soit le numéro d'id (valide) passé.

    Je comprend rien. vous auriez une idée du problème ? Merci.

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

    Informations forums :
    Inscription : Novembre 2006
    Messages : 7 310
    Points : 9 522
    Points
    9 522
    Billets dans le blog
    1
    Par défaut
    J'ai perdu ma boule de cristal...

    Il faudrait au minimum donner la requête exécutée et la structure de la base de données (pour les tables utilisées)
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  3. #3
    Membre averti Avatar de BakaOnigiri
    Inscrit en
    Avril 2002
    Messages
    366
    Détails du profil
    Informations forums :
    Inscription : Avril 2002
    Messages : 366
    Points : 437
    Points
    437
    Par défaut
    désolé

    voici la requête (assez simple) :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    @NamedQuery(name = "Journal.findFromId", query = "SELECT j FROM Journal j WHERE j.id = :cID"),
    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
    mysql> desc journal;
    +----------------------+-----------------------------------------------------+------+-----+---------------------+----------------+
    | Field                | Type                                                | Null | Key | Default             | Extra          |
    +----------------------+-----------------------------------------------------+------+-----+---------------------+----------------+
    | ID                   | int(11)                                             | NO   | PRI | NULL                | auto_increment | 
    | NUM                  | int(11)                                             | NO   |     | NULL                |                | 
    | TYPE                 | varchar(30)                                         | NO   |     | NULL                |                | 
    | ARC                  | int(11)                                             | NO   |     | 0                   |                | 
    | LIEU                 | varchar(60)                                         | NO   |     | NULL                |                | 
    | NUM_MODELE           | int(11)                                             | NO   |     | NULL                |                | 
    | TITRE                | varchar(40)                                         | NO   |     | NULL                |                | 
    | TEXTE                | varchar(200)                                        | NO   |     | NULL                |                | 
    | COMMENTAIRE          | varchar(200)                                        | NO   |     | NULL                |                | 
    | HORO_CREATION        | timestamp                                           | NO   |     | 0000-00-00 00:00:00 |                | 
    | HORO_VERSION         | timestamp                                           | NO   |     | 0000-00-00 00:00:00 |                | 
    | HORO_DEBUT           | timestamp                                           | NO   |     | 0000-00-00 00:00:00 |                | 
    | HORO_FIN             | timestamp                                           | NO   |     | 0000-00-00 00:00:00 |                | 
    | HORO_DIFFUSION       | timestamp                                           | NO   |     | 0000-00-00 00:00:00 |                | 
    | DIFFUSION_ICONE_SYNO | tinyint(1)                                          | NO   |     | 0                   |                | 
    | DIFFUSION_ICONE_WEB  | tinyint(1)                                          | NO   |     | 0                   |                | 
    | DIFFUSION_LISTE_WEB  | tinyint(1)                                          | NO   |     | 0                   |                | 
    | DIFFUSION_PDA        | tinyint(1)                                          | NO   |     | 0                   |                | 
    | ETAT                 | enum('WAIT_START','WAIT_END','FINISHED','MODIFIED') | NO   |     | NULL                |                | 
    +----------------------+-----------------------------------------------------+------+-----+---------------------+----------------+
    19 rows in set (0.00 sec)
    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
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    /*
     * @(#)Journal.java   20.11.08
     */
     
     
     
    package traffic.dao;
     
    //~--- JDK imports ------------------------------------------------------------
     
    import java.io.Serializable;
     
    import java.util.Date;
     
    import javax.persistence.Basic;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.NamedQueries;
    import javax.persistence.NamedQuery;
    import javax.persistence.Table;
    import javax.persistence.Temporal;
    import javax.persistence.TemporalType;
     
    //~--- classes ----------------------------------------------------------------
     
    @Entity @Table(name	= "journal")
    @NamedQueries(
    {
    	@NamedQuery(name = "Journal.findAll", query	= "SELECT j FROM Journal j"),
        @NamedQuery(name = "Journal.findAllActive", query = "SELECT j FROM Journal j WHERE j.etat != 'MODIFIED' AND j.etat != 'FINISHED'"),
        @NamedQuery(name = "Journal.findFromId", query = "SELECT j FROM Journal j WHERE j.id = :cID"),
        @NamedQuery(name = "Journal.findFromNum", query	= "SELECT j FROM Journal j WHERE j.id = (SELECT MAX(t.id) FROM Journal t WHERE t.num = :cNUM)"),
        @NamedQuery(name = "Journal.findNextEvt", query = "SELECT MAX(j.num) FROM Journal j")
    })
    public class Journal implements Serializable, Cloneable
    {
    	private static final long	serialVersionUID	= 1L;
    	@Basic(optional	= false)
    	@Column(name = "ARC")
    	private int					arc;
    	@Basic(optional	= false)
    	@Column(name = "COMMENTAIRE")
    	private String				commentaire;
    	@Basic(optional	= false)
    	@Column(name = "DIFFUSION_ICONE_SYNO")
    	private Boolean				diffusionIconeSyno;
    	@Basic(optional	= false)
    	@Column(name = "DIFFUSION_ICONE_WEB")
    	private Boolean				diffusionIconeWeb;
    	@Basic(optional	= false)
    	@Column(name = "DIFFUSION_LISTE_WEB")
    	private Boolean				diffusionListeWeb;
    	@Basic(optional	= false)
    	@Column(name = "DIFFUSION_PDA")
    	private Boolean				diffusionPda;
    	@Basic(optional	= false)
    	@Column(name = "ETAT")
    	private String				etat;
    	@Basic(optional	= false)
    	@Column(name = "HORO_CREATION")
    	@Temporal(TemporalType.TIMESTAMP)
    	private Date				horoCreation;
    	@Basic(optional	= false)
    	@Column(name = "HORO_DEBUT")
    	@Temporal(TemporalType.TIMESTAMP)
    	private Date				horoDebut;
    	@Basic(optional	= false)
    	@Column(name = "HORO_DIFFUSION")
    	@Temporal(TemporalType.TIMESTAMP)
    	private Date				horoDiffusion;
    	@Basic(optional	= false)
    	@Column(name = "HORO_FIN")
    	@Temporal(TemporalType.TIMESTAMP)
    	private Date				horoFin;
    	@Basic(optional	= false)
    	@Column(name = "HORO_VERSION")
    	@Temporal(TemporalType.TIMESTAMP)
    	private Date				horoVersion;
    	@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
    	@Basic(optional	= false)
    	@Column(name = "ID")
    	private Integer				id;
    	@Basic(optional	= false)
    	@Column(name = "LIEU")
    	private String				lieu;
    	@Basic(optional	= false)
    	@Column(name = "NUM")
    	private int					num;
    	@Basic(optional	= false)
    	@Column(name = "NUM_MODELE")
    	private int					numModele;
    	@Basic(optional	= false)
    	@Column(name = "TEXTE")
    	private String				texte;
    	@Basic(optional	= false)
    	@Column(name = "TITRE")
    	private String				titre;
    	@Basic(optional	= false)
    	@Column(name = "TYPE")
    	private String				type;
     
    	public Journal(){}
     
    	public Journal(Integer id)
    	{
    		this.id	= id;
    	}
     
    	public Journal(Integer id, int num, String type, int arc, String lieu, String titre, String texte, String commentaire, Date horoCreation, Date horoVersion, Date horoDebut, Date horoFin, Date horoDiffusion)
    	{
    		this.id				= id;
    		this.num			= num;
    		this.type			= type;
    		this.arc			= arc;
    		this.lieu			= lieu;
    		this.titre			= titre;
    		this.texte			= texte;
    		this.commentaire	= commentaire;
    		this.horoCreation	= horoCreation;
    		this.horoVersion	= horoVersion;
    		this.horoDebut		= horoDebut;
    		this.horoFin		= horoFin;
    		this.horoDiffusion	= horoDiffusion;
    	}
     
        public Journal(int arc, String commentaire, Boolean diffusionIconeSyno, Boolean diffusionIconeWeb, Boolean diffusionListeWeb, Boolean diffusionPda, String etat, Date horoCreation, Date horoDebut, Date horoDiffusion, Date horoFin, Date horoVersion, Integer id, String lieu, int num, int numModele, String texte, String titre, String type) {
            this.arc = arc;
            this.commentaire = commentaire;
            this.diffusionIconeSyno = diffusionIconeSyno;
            this.diffusionIconeWeb = diffusionIconeWeb;
            this.diffusionListeWeb = diffusionListeWeb;
            this.diffusionPda = diffusionPda;
            this.etat = etat;
            this.horoCreation = horoCreation;
            this.horoDebut = horoDebut;
            this.horoDiffusion = horoDiffusion;
            this.horoFin = horoFin;
            this.horoVersion = horoVersion;
            this.id = id;
            this.lieu = lieu;
            this.num = num;
            this.numModele = numModele;
            this.texte = texte;
            this.titre = titre;
            this.type = type;
        }
     
    	public Integer getId()
    	{
    		return id;
    	}
     
    	public void setId(Integer id)
    	{
    		this.id	= id;
    	}
     
    	public int getNum()
    	{
    		return num;
    	}
     
    	public void setNum(int num)
    	{
    		this.num	= num;
    	}
     
    	public String getType()
    	{
    		return type;
    	}
     
    	public void setType(String type)
    	{
    		this.type	= type;
    	}
     
    	public int getArc()
    	{
    		return arc;
    	}
     
    	public void setArc(int arc)
    	{
    		this.arc	= arc;
    	}
     
    	public String getLieu()
    	{
    		return lieu;
    	}
     
    	public void setLieu(String lieu)
    	{
    		this.lieu	= lieu;
    	}
     
    	public String getTitre()
    	{
    		return titre;
    	}
     
    	public void setTitre(String titre)
    	{
    		this.titre	= titre;
    	}
     
    	public String getTexte()
    	{
    		return texte;
    	}
     
    	public void setTexte(String texte)
    	{
    		this.texte	= texte;
    	}
     
    	public String getCommentaire()
    	{
    		return commentaire;
    	}
     
    	public void setCommentaire(String commentaire)
    	{
    		this.commentaire	= commentaire;
    	}
     
    	public Date getHoroCreation()
    	{
    		return horoCreation;
    	}
     
    	public void setHoroCreation(Date horoCreation)
    	{
    		this.horoCreation	= horoCreation;
    	}
     
    	public Date getHoroVersion()
    	{
    		return horoVersion;
    	}
     
    	public void setHoroVersion(Date horoVersion)
    	{
    		this.horoVersion	= horoVersion;
    	}
     
    	public Date getHoroDebut()
    	{
    		return horoDebut;
    	}
     
    	public void setHoroDebut(Date horoDebut)
    	{
    		this.horoDebut	= horoDebut;
    	}
     
    	public Date getHoroFin()
    	{
    		return horoFin;
    	}
     
    	public void setHoroFin(Date horoFin)
    	{
    		this.horoFin	= horoFin;
    	}
     
    	public Date getHoroDiffusion()
    	{
    		return horoDiffusion;
    	}
     
    	public void setHoroDiffusion(Date horoDiffusion)
    	{
    		this.horoDiffusion	= horoDiffusion;
    	}
     
    	public Boolean getDiffusionIconeSyno()
    	{
    		return diffusionIconeSyno;
    	}
     
    	public void setDiffusionIconeSyno(Boolean diffusionIconeSyno)
    	{
    		this.diffusionIconeSyno	= diffusionIconeSyno;
    	}
     
    	public Boolean getDiffusionIconeWeb()
    	{
    		return diffusionIconeWeb;
    	}
     
    	public void setDiffusionIconeWeb(Boolean diffusionIconeWeb)
    	{
    		this.diffusionIconeWeb	= diffusionIconeWeb;
    	}
     
    	public Boolean getDiffusionListeWeb()
    	{
    		return diffusionListeWeb;
    	}
     
    	public void setDiffusionListeWeb(Boolean diffusionListeWeb)
    	{
    		this.diffusionListeWeb	= diffusionListeWeb;
    	}
     
    	public Boolean getDiffusionPda()
    	{
    		return diffusionPda;
    	}
     
    	public void setDiffusionPda(Boolean diffusionPda)
    	{
    		this.diffusionPda	= diffusionPda;
    	}
     
    	public String getEtat()
    	{
    		return etat;
    	}
     
    	public void setEtat(String etat)
    	{
    		this.etat	= etat;
    	}
     
    	public int getNumModele()
    	{
    		return numModele;
    	}
     
    	public void setNumModele(int numModele)
    	{
    		this.numModele	= numModele;
    	}
     
    	@Override
    	public int hashCode()
    	{
    		int	hash	= 0;
     
    		hash	+= ((id != null) ? id.hashCode() : 0);
     
    		return hash;
    	}
     
    	@Override
    	public boolean equals(Object obj)
    	{
    		if(obj == null)
    		{
    			return false;
    		}
     
    		if(getClass() != obj.getClass())
    		{
    			return false;
    		}
     
    		final Journal	other	= (Journal) obj;
     
    		if(this.arc != other.arc)
    		{
    			return false;
    		}
     
    		if((this.commentaire == null) ? (other.commentaire != null) : !this.commentaire.equals(other.commentaire))
    		{
    			return false;
    		}
     
    		if((this.diffusionIconeSyno != other.diffusionIconeSyno) && ((this.diffusionIconeSyno == null) || !this.diffusionIconeSyno.equals(other.diffusionIconeSyno)))
    		{
    			return false;
    		}
     
    		if((this.diffusionIconeWeb != other.diffusionIconeWeb) && ((this.diffusionIconeWeb == null) || !this.diffusionIconeWeb.equals(other.diffusionIconeWeb)))
    		{
    			return false;
    		}
     
    		if((this.diffusionListeWeb != other.diffusionListeWeb) && ((this.diffusionListeWeb == null) || !this.diffusionListeWeb.equals(other.diffusionListeWeb)))
    		{
    			return false;
    		}
     
    		if((this.diffusionPda != other.diffusionPda) && ((this.diffusionPda == null) || !this.diffusionPda.equals(other.diffusionPda)))
    		{
    			return false;
    		}
     
    		if((this.horoCreation != other.horoCreation) && ((this.horoCreation == null) || !this.horoCreation.equals(other.horoCreation)))
    		{
    			return false;
    		}
     
    		if((this.horoDebut != other.horoDebut) && ((this.horoDebut == null) || !this.horoDebut.equals(other.horoDebut)))
    		{
    			return false;
    		}
     
    		if((this.horoDiffusion != other.horoDiffusion) && ((this.horoDiffusion == null) || !this.horoDiffusion.equals(other.horoDiffusion)))
    		{
    			return false;
    		}
     
    		if((this.horoFin != other.horoFin) && ((this.horoFin == null) || !this.horoFin.equals(other.horoFin)))
    		{
    			return false;
    		}
     
    		if((this.lieu == null) ? (other.lieu != null) : !this.lieu.equals(other.lieu))
    		{
    			return false;
    		}
     
    		if(this.num != other.num)
    		{
    			return false;
    		}
     
    		if((this.texte == null) ? (other.texte != null) : !this.texte.equals(other.texte))
    		{
    			return false;
    		}
     
    		if((this.titre == null) ? (other.titre != null) : !this.titre.equals(other.titre))
    		{
    			return false;
    		}
     
    		if((this.type == null) ? (other.type != null) : !this.type.equals(other.type))
    		{
    			return false;
    		}
     
    		return true;
    	}
     
    	@Override
    	public Object clone() throws CloneNotSupportedException
    	{
    		return super.clone();
    	}
     
    	@Override
    	public String toString()
    	{
    		StringBuilder	str	= new StringBuilder();
     
    		str.append("traffic.dao.Journal[id=");
    		str.append(id);
    		str.append(",num=");
    		str.append(num);
    		str.append(",type=");
    		str.append(type);
    		str.append(",arc=");
    		str.append(arc);
    		str.append(",lieu=");
    		str.append(lieu);
    		str.append(",titre=");
    		str.append(titre);
    		str.append(",texte=");
    		str.append(texte);
    		str.append(",commentaire=");
    		str.append(commentaire);
    		str.append(",horoCreation=");
    		str.append(horoCreation);
    		str.append(",horoVersion=");
    		str.append(horoVersion);
    		str.append(",horoDebut=");
    		str.append(horoDebut);
    		str.append(",horoFin=");
    		str.append(horoFin);
    		str.append(",horoDiffusion=");
    		str.append(horoDiffusion);
    		str.append("]");
     
    		return str.toString();
    	}
    }
    C'est cela que je devais fournir ? merci en tout cas.

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

    Informations forums :
    Inscription : Novembre 2006
    Messages : 7 310
    Points : 9 522
    Points
    9 522
    Billets dans le blog
    1
    Par défaut
    Oui, c'est bien ça...

    ID est la clé primaire de la table Journal ?
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  5. #5
    Membre averti Avatar de BakaOnigiri
    Inscrit en
    Avril 2002
    Messages
    366
    Détails du profil
    Informations forums :
    Inscription : Avril 2002
    Messages : 366
    Points : 437
    Points
    437
    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
    mysql> select * from journal;
    +----+-----+--------------------------+------+------------------+------------+---------------+--------------------+-----------------+---------------------+---------------------+---------------------+---------------------+---------------------+----------------------+---------------------+---------------------+---------------+------------+
    | ID | NUM | TYPE                     | ARC  | LIEU             | NUM_MODELE | TITRE         | TEXTE              | COMMENTAIRE     | HORO_CREATION       | HORO_VERSION        | HORO_DEBUT          | HORO_FIN            | HORO_DIFFUSION      | DIFFUSION_ICONE_SYNO | DIFFUSION_ICONE_WEB | DIFFUSION_LISTE_WEB | DIFFUSION_PDA | ETAT       |
    +----+-----+--------------------------+------+------------------+------------+---------------+--------------------+-----------------+---------------------+---------------------+---------------------+---------------------+---------------------+----------------------+---------------------+---------------------+---------------+------------+
    |  1 |  11 | Message std              |    0 | Rue des Bouchers |          0 | %type% %lieu% | %lieu%             | plop            | 2008-11-06 13:58:10 | 2008-11-06 13:58:10 | 2008-05-18 10:00:00 | 2008-05-18 12:00:00 | 2008-05-16 07:00:00 |                    0 |                   0 |                   0 |             0 | MODIFIED   | 
    |  2 |  11 | Message std              | 1006 | Rue des Bouchers |          0 | %type% %lieu% | %lieu%             | plop....        | 2008-11-06 13:58:10 | 2008-11-06 14:05:02 | 2008-05-18 10:00:00 | 2008-05-18 12:00:00 | 2008-05-16 07:00:00 |                    0 |                   0 |                   0 |             0 | FINISHED   | 
    |  3 |  15 |                          |    0 |                  |          0 |               |                    |                 | 2008-11-17 09:41:00 | 2008-11-17 09:41:00 | 2008-11-20 10:10:00 | 2008-11-21 12:10:00 | 2008-11-20 10:10:00 |                    0 |                   0 |                   0 |             0 | MODIFIED   | 
    |  4 |  15 |                          |    0 |                  |          0 |               |                    |                 | 2008-11-17 09:41:00 | 2008-11-17 16:01:00 | 2008-11-20 10:10:00 | 2008-11-21 12:10:00 | 2008-11-20 10:10:00 |                    0 |                   0 |                   0 |             0 | MODIFIED   | 
    |  5 |  15 | Hum                      |   42 | Là bas           |          1 | %evt%         | %lieu%             | Test conception | 2008-11-17 09:41:00 | 2008-11-18 10:35:00 | 2008-11-20 10:10:00 | 2008-11-21 12:10:00 | 2008-11-20 10:10:00 |                    1 |                   0 |                   1 |             0 | WAIT_START | 
    |  6 |  16 | ...                      |    1 | Plop             |          0 | %type%        | %type% => %lieu%   | Commentaire     | 2008-12-04 10:09:51 | 2008-12-04 10:09:51 | 2008-12-05 10:20:00 | 2008-12-06 12:30:00 | 2008-12-05 11:10:00 |                    1 |                   0 |                   0 |             0 | WAIT_START | 
    +----+-----+--------------------------+------+------------------+------------+---------------+--------------------+-----------------+---------------------+---------------------+---------------------+---------------------+---------------------+----------------------+---------------------+---------------------+---------------+------------+
    6 rows in set (0.00 sec)

  6. #6
    Membre averti Avatar de BakaOnigiri
    Inscrit en
    Avril 2002
    Messages
    366
    Détails du profil
    Informations forums :
    Inscription : Avril 2002
    Messages : 366
    Points : 437
    Points
    437
    Par défaut
    En effet, ID est une clef primaire auto incrémentée, et demander l'enregistrement 5 fonctionne, mais pas le 6 ni le 4

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

    Informations forums :
    Inscription : Novembre 2006
    Messages : 7 310
    Points : 9 522
    Points
    9 522
    Billets dans le blog
    1
    Par défaut
    C'est curieux... l'exception est lancée quand il ne trouve pas d'enregistrement... et tu dis qu'ils existent...
    Là, je ne vois pas...

    A tout hasard, essaye de faire setParameter("cID", new Integer(id));

    Tu utilises quelle version d'hibernate ?
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  8. #8
    Membre averti Avatar de BakaOnigiri
    Inscrit en
    Avril 2002
    Messages
    366
    Détails du profil
    Informations forums :
    Inscription : Avril 2002
    Messages : 366
    Points : 437
    Points
    437
    Par défaut
    bon le new Integer ne change rien.

    Le truc qui me chifonne, c'est que j'ai bien un résultat, Object t est bien remplis, et le println appelle bien la méthode toString surchargée, j'ai donc bien l'enregistrement dans mes traces, mais le cast du return génère l'exception.

    D'après le nom du .jar çà serais hibernate 3, mais je ne sais pas la version exacte, je vais chercher.

    EDIT : mon fichier hibernate-core.jar est la version 3.3.0.SP1, hibernate-commons-annotations : 3.1.0.GA, hibernate-annotations : 3.4.0.GA

  9. #9
    Membre confirmé
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    383
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2007
    Messages : 383
    Points : 468
    Points
    468
    Par défaut
    Pourquoi tu mets "select j" dans ta requete ?

    Essaye plutôt :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    @NamedQuery(name = "Journal.findFromId", query = "from Journal j where j.id = :cID")

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

    Informations forums :
    Inscription : Novembre 2006
    Messages : 7 310
    Points : 9 522
    Points
    9 522
    Billets dans le blog
    1
    Par défaut
    Citation Envoyé par BakaOnigiri Voir le message
    bon le new Integer ne change rien.

    Le truc qui me chifonne, c'est que j'ai bien un résultat, Object t est bien remplis, et le println appelle bien la méthode toString surchargée, j'ai donc bien l'enregistrement dans mes traces, mais le cast du return génère l'exception.

    D'après le nom du .jar çà serais hibernate 3, mais je ne sais pas la version exacte, je vais chercher.

    EDIT : mon fichier hibernate-core.jar est la version 3.3.0.SP1, hibernate-commons-annotations : 3.1.0.GA, hibernate-annotations : 3.4.0.GA
    Oui mais là, il y a un truc qui ne va pas...

    Une ClassCastException n'est pas une NoResultException, tu peux afficher la stackTrace ?

    Tu peux également ajouter un System.out.println(t.getClass().getName());
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  11. #11
    Membre averti Avatar de BakaOnigiri
    Inscrit en
    Avril 2002
    Messages
    366
    Détails du profil
    Informations forums :
    Inscription : Avril 2002
    Messages : 366
    Points : 437
    Points
    437
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    System.out.println("--------------------- " + id);
    [#|2008-12-04T13:23:08.759+0100|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=26;_ThreadName=httpSSLWorkerThread-8080-1;|
    --------------------- 6|#]
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    System.out.println(t.getClass().getName());
    [#|2008-12-04T13:23:08.762+0100|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=26;_ThreadName=httpSSLWorkerThread-8080-1;|
    traffic.dao.Journal|#]
    [#|2008-12-04T13:23:08.762+0100|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=26;_ThreadName=httpSSLWorkerThread-8080-1;|
    traffic.dao.Journal[id=6,num=16,type=Manifestation officielle,arc=1,lieu=Plop,titre=%type%,texte=%type% => %lieu%,commentaire=Commentaire,horoCreation=2008-12-04 10:09:51.0,horoVersion=2008-12-04 10:09:51.0,horoDebut=2008-12-05 10:20:00.0,horoFin=2008-12-06 12:30:00.0,horoDiffusion=2008-12-05 11:10:00.0]|#]
    [#|2008-12-04T13:23:08.770+0100|SEVERE|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=26;_ThreadName=httpSSLWorkerThread-8080-1;_RequestID=8c53442d-7e8b-47aa-a6d3-01e1ca60a27c;|StandardWrapperValve[ServletAdaptor]: PWC1406 : servlet.service() pour le servlet ServletAdaptor a émis une exception.
    javax.persistence.NoResultException: No entity found for query
    at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:104)
    at com.sun.enterprise.util.QueryWrapper.getSingleResult(QueryWrapper.java:212)
    at traffic.dao.ModeleDAO.getFromID(ModeleDAO.java:50)
    at traffic.jersey.MceAffEvt.getPageContent(MceAffEvt.java:410)
    at traffic.jersey.MceAffEvt.getConsultation(MceAffEvt.java:48)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.jersey.impl.model.method.dispatch.EntityParamDispatchProvider$TypeOutInvoker._dispatch(EntityParamDispatchProvider.java:136)
    at com.sun.jersey.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:85)
    at com.sun.jersey.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:123)
    at com.sun.jersey.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:111)
    at com.sun.jersey.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:71)
    at com.sun.jersey.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:111)
    at com.sun.jersey.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:63)
    at com.sun.jersey.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:722)
    at com.sun.jersey.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:692)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:344)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
    at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:290)
    at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
    at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
    at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
    at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
    at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
    at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
    at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
    at com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:380)
    at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
    at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
    |#]

  12. #12
    Membre averti Avatar de BakaOnigiri
    Inscrit en
    Avril 2002
    Messages
    366
    Détails du profil
    Informations forums :
    Inscription : Avril 2002
    Messages : 366
    Points : 437
    Points
    437
    Par défaut
    Bon j'ai trouvé, désolé pour tout le dérangement

    je viens de mieux lire la stack :
    at traffic.dao.ModeleDAO.getFromID(ModeleDAO.java:50)
    J'ai un problème lors de la récupération d'un Modele et pas d'un Journal, ici :
    at traffic.jersey.MceAffEvt.getPageContent(MceAffEvt.java:410)
    or, ici (ligne 410), j'ai çà :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    mdl = new ModeleDAO().getFromID(jnal.getNumModele());
    , mais si getNumModele() retourne null, ou une valeur qui n'est pas dans la table Modele, c'est tout à fait logique.

    Donc en fait l'erreur est normale et tout est de ma faute, désolé.

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

Discussions similaires

  1. recuperer les query qui n'ont sont no hits found blast
    Par karaudrey88 dans le forum Bioinformatique
    Réponses: 2
    Dernier message: 12/12/2012, 16h47
  2. formule index qui marche par moment
    Par manguigs dans le forum Excel
    Réponses: 3
    Dernier message: 23/10/2012, 11h12
  3. Envoi de html par mail qui marche mal
    Par laurentSc dans le forum Langage
    Réponses: 7
    Dernier message: 12/08/2010, 23h22
  4. [CS4] encodage UTF8 par defaut qui marche pas
    Par sylvain_webprod dans le forum Dreamweaver
    Réponses: 1
    Dernier message: 05/11/2009, 15h59
  5. no persistent classes found for query class
    Par jamalmoundir dans le forum Hibernate
    Réponses: 4
    Dernier message: 12/07/2007, 15h19

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