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

Persistance des données Java Discussion :

[Débutant] Ssimple requête JPQL


Sujet :

Persistance des données Java

  1. #1
    Membre à l'essai
    Inscrit en
    Septembre 2010
    Messages
    27
    Détails du profil
    Informations forums :
    Inscription : Septembre 2010
    Messages : 27
    Points : 14
    Points
    14
    Par défaut [Débutant] Ssimple requête JPQL
    Bonjour !
    Quelqu'un pourrait-il me dire pourquoi cette méthode ne marche pas? (j'espère être au bon endroit ^^')

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    @Transactional
    @Override
    public List<Cote> findCotesMatch(Integer id){
        //query.setParameter("idm", id);
        Query query = em.createQuery("SELECT e FROM Cote WHERE e.idMatch = :idm"); 
        query.setParameter("idm", id);
          return (List<Cote>) query.getResultList();
    }
    que j'appelle ici :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
      @RequestMapping(value = "/showcotematch.htm")
         public String showCoteMatch(ModelMap modelmap) {       
     
           modelmap.addAttribute("listCote", repocote.findCotesMatch(2));        
             return "cote/coteRecordForm"; 
        }
    et voila l'erreur que j'ai en sortie:

    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
     
    java.lang.IllegalArgumentException: org.hibernate.QueryException: Unable to resolve path [e.idMatch], unexpected token [e] [SELECT e FROM fr.ensiie.previsionsport.data.domain.foot.Cote WHERE e.idMatch = :idm]
    	org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1222)
    	org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1168)
    	org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:271)
    	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	java.lang.reflect.Method.invoke(Method.java:597)
    	org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240)
    	$Proxy80.createQuery(Unknown Source)
    	fr.ensiie.previsionsport.repository.foot.CoteRepositoryImpl.findCotesMatch(CoteRepositoryImpl.java:72)
    	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	java.lang.reflect.Method.invoke(Method.java:597)
    	org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
    	org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
    	org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    	org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155)
    	org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    	org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
    	org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    	org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    	$Proxy90.findCotesMatch(Unknown Source)
    	fr.ensiie.previsionsport.mvc.controller.foot.GestionCoteController.showCoteMatch(GestionCoteController.java:44)
    	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	java.lang.reflect.Method.invoke(Method.java:597)
    	org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
    	org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)
    	org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
    	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
    	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
    	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    	org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
    Un peu d'aide ne serait pas de refus

  2. #2
    Membre à l'essai
    Inscrit en
    Septembre 2010
    Messages
    27
    Détails du profil
    Informations forums :
    Inscription : Septembre 2010
    Messages : 27
    Points : 14
    Points
    14
    Par défaut
    la solution était :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    @Transactional
    @Override
    public List<Cote> findCotesMatch(Integer id){
        //query.setParameter("idm", id);
        Query query = em.createQuery("SELECT e FROM Cote WHERE e.idMatch = "+id); 
     
          return (List<Cote>) query.getResultList();
    }
    j'avais l'habitude de mettre " : " d'où le problème

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

Discussions similaires

  1. débutant : probleme requête
    Par regis94 dans le forum Access
    Réponses: 5
    Dernier message: 17/08/2006, 13h31
  2. Réponses: 33
    Dernier message: 06/06/2006, 14h41
  3. [Débutant / SQL] Requête avec la fonction MAX
    Par bugmenot dans le forum Access
    Réponses: 3
    Dernier message: 14/04/2006, 10h43
  4. [Débutant] Conception requêtes SQL
    Par LhIaScZkTer dans le forum Langage SQL
    Réponses: 15
    Dernier message: 10/01/2006, 21h46
  5. [Débutant]Soucis requête jointure externes (8-i)
    Par jdotti dans le forum Oracle
    Réponses: 7
    Dernier message: 14/10/2005, 15h39

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