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

JPA Java Discussion :

java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to javaapplication2.components.VopD


Sujet :

JPA Java

Vue hybride

Message pr�c�dent Message pr�c�dent   Message suivant Message suivant
  1. #1
    Membre �clair�
    Inscrit en
    Mai 2003
    Messages
    351
    D�tails du profil
    Informations forums :
    Inscription : Mai 2003
    Messages : 351
    Par d�faut java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to javaapplication2.components.VopD
    je suis toujours confront� au probl�me de casting
    le model
    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
    public void setData(java.util.List<javaapplication2.components.VopD> dataList){
          m_frm = new SimpleDateFormat("MM/dd/yyyy");
          model.removeAllElements();
         //Object[] values = dataList.getSelectedValues();
         for (int i = 0; i<dataList.size(); i++) {
            //outputListModel.addElement(values[i]);
            model.addElement(new VopData(dataList.get(i).structure,
                                         dataList.get(i).nature,
                                         dataList.get(i).libelle,
                                         dataList.get(i).objet,
                                         dataList.get(i).date_deb,
                                         dataList.get(i).date_fin,
                                         dataList.get(i).montant,
                                         dataList.get(i).paye));
         }
         // the table model is interested in changes of the rows
         fireTableRowsInserted(model.size()-1, model.size()-1);
      }
    classe pour r�cup�rer des donn�es de la base
    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    public class VopD {
           public Structure  structure;
           public Nature  nature;
           public String  libelle;
           public String  objet;
           public Date    date_deb;
           public Date    date_fin;
           public Long    montant;
           public Long    paye;
        }
    classe correspondante � VopD mais pour formatter les donn�es afin de les afficher
    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
     private IconData  structure;
      private Integer   nature;
      private String    libelle;
      private String    objet;
      private Date      date_deb;
      private Date      date_fin;
      private SmartLong montant;
      private SmartLong paye;
      private float     progress;
     
      public VopData(Structure structure,
                     Nature nature,
                     String libelle,
                     String objet,
                     Date date_deb,
                     Date date_fin,
                     Long montant,
                     Long paye){
    	 this.structure = new IconData(getIcon(montant,paye), structure.getCode());
    	 this.nature    = nature.getCode();
             this.libelle = libelle;
    	 this.objet = objet;
             this.date_deb = date_deb;
    	 this.date_fin = date_fin;
             this.montant = new SmartLong(montant);
    	 this.nature = nature.getCode();
             this.paye = new SmartLong(paye);
    	 this.progress = (float)((paye/montant) * 100);
      }
    la requ�te pour r�cuperer les donn�es
    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    private javaapplication2.components.VopModel model;
        private java.util.List<javaapplication2.components.VopD> VopDataList;
        private javax.persistence.Query VopDataQuery;
     
    VopDataQuery = java.beans.Beans.isDesignTime() ? null : gestcomPUEntityManager.createQuery("select o.code,o.libelle,o.objet,o.montant,o.datefin,o.datedeb,o.datesais,o.statut,o.structure,o.nature,e.sens,sum(e.montant) from Operation o, Ecriture e where o.code = e.operation.code and e.sens = 'C' group by o.code,o.libelle,o.objet,o.montant,o.datefin,o.datedeb,o.datesais,o.statut,o.structure,o.nature,e.sens");
            VopDataList = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : VopDataQuery.getResultList();
            model = new javaapplication2.components.VopModel(VopDataList);
            masterTable.setModel(model);
    et l'erreur:
    Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to javaapplication2.components.VopD
    at javaapplication2.components.VopModel.setData(VopModel.java:90)
    at javaapplication2.components.VopModel.<init>(VopModel.java:81)
    at javaapplication2.view.F_Consul_Operation.initComponents(F_Consul_Operation.java:119)
    at javaapplication2.view.F_Consul_Operation.<init>(F_Consul_Operation.java:28)
    at javaapplication2.view.F_Consul_Operation$2.run(F_Consul_Operation.java:201)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    BUILD SUCCESSFUL (total time: 3 seconds)

  2. #2
    Membre �clair�
    Inscrit en
    Mai 2003
    Messages
    351
    D�tails du profil
    Informations forums :
    Inscription : Mai 2003
    Messages : 351
    Par d�faut
    j'ai essayer de faire court en affichant directement le contenu de la List
    et j'ai la m�me erreur.
    Apparemment la liste ne contient pas des donn�es de type VopD.
    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
    3
    4
    5
    VopDataQuery = java.beans.Beans.isDesignTime() ? null : gestcomPUEntityManager.createQuery("select o.code,o.libelle,o.objet,o.montant,o.datefin,o.datedeb,o.datesais,o.statut,o.structure,o.nature,e.sens,sum(e.montant) from Operation o, Ecriture e where o.code = e.operation.code and e.sens = 'C' group by o.code,o.libelle,o.objet,o.montant,o.datefin,o.datedeb,o.datesais,o.statut,o.structure,o.nature,e.sens");
    VopDataList = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : VopDataQuery.getResultList();
    for (javaapplication2.components.VopD o : VopDataList) {
         System.out.println("Libellé :"+ o.libelle);
    }
    Je ne comprends pas dans la mesure o� je l'ai declar� une liste de VopD
    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    private java.util.List<javaapplication2.components.VopD> VopDataList;

Discussions similaires

  1. java.lang.ClassCastException: $Proxy2 cannot be cast
    Par olivier57b dans le forum Java EE
    R�ponses: 0
    Dernier message: 14/07/2010, 20h52
  2. R�ponses: 1
    Dernier message: 26/04/2010, 11h03
  3. R�ponses: 3
    Dernier message: 30/09/2009, 11h36
  4. ClassCastException: [Ljava.lang.Object et Liste
    Par lepetitjoe dans le forum Langage
    R�ponses: 14
    Dernier message: 26/06/2008, 18h29
  5. java.lang.object cannot be resolved
    Par hammag dans le forum Servlets/JSP
    R�ponses: 9
    Dernier message: 24/06/2007, 11h32

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