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

Struts 1 Java Discussion :

Ignoring the @NamedQuery [xx] specified on class [jpa.Article] since a query with that name already exists.


Sujet :

Struts 1 Java

  1. #1
    Membre à l'essai
    Homme Profil pro
    R&D
    Inscrit en
    Décembre 2013
    Messages
    32
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : R&D
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2013
    Messages : 32
    Points : 16
    Points
    16
    Par défaut Ignoring the @NamedQuery [xx] specified on class [jpa.Article] since a query with that name already exists.
    Bonjour,

    already exist ... Cette donnée est déjà effectivement utilisée mais dans un autre package.java,

    OU est mon erreur , j'ai 2 tables postgresql ( article & bilan) et je dois afficher une donnée de chacune dans le popup de mon IHM.
    Les données des la tables sont ensuite utilisées dans des tags pour calculs qui sont enregistrés dans la table article.

    GLASSFISH ME DIT CECI : Ignoring the @NamedQuery [Bilanprevisionnel.findByBipDecTauxmargeSurheure] specified on class [jpa.Article] since a query with that name already exists.

    Pourtant j'ai bien mes tables (article & bilan) dans le JPA, je voulais savoir si mon erreur se situe ici ?

    article.java
    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
    package jpa;
     
    import java.io.Serializable;
    import java.math.BigDecimal;
    import java.util.Collection;
    import java.util.Date;
    import javax.persistence.Basic;
    import javax.persistence.CascadeType;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.FetchType;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.JoinColumn;
    import javax.persistence.ManyToOne;
    import javax.persistence.NamedQueries;
    import javax.persistence.NamedQuery;
    import javax.persistence.OneToMany;
    import javax.persistence.SequenceGenerator;
    import javax.persistence.Table;
    import javax.persistence.Temporal;
    import javax.persistence.TemporalType;
     
    /**
     * @author XXXXX
     */
    @Entity
    @Table(name = "article", catalog = "xxx", schema = "public")
    @NamedQueries({@NamedQuery(name = "Article.findAll", query = "SELECT a FROM Article a"),
    @NamedQuery(name = "Article.findByArtIntId", query = "SELECT a FROM Article a WHERE a.artIntId = :artIntId"),
    ....
    @NamedQuery(name = "Article.findByArtDecPrix", query = "SELECT a FROM Article a WHERE a.artDecPrix = :artDecPrix"),
    @NamedQuery(name = "Article.findByArtDecCoefnum", query = "SELECT a FROM Article a WHERE a.artDecCoefnum = :artDecCoefnum"),
    @NamedQuery(name = "Article.findByArtDecResultprixventeanalytique", query = "SELECT a FROM Article a WHERE a.artDecResultprixventeanalytique = :artDecResultprixventeanalytique"),
    ..
    // ma table Bilan "ignorée"
    @NamedQuery(name = "Bilan.findByBipDecTauxmarge", query = "SELECT b FROM Bilan b WHERE b.bipDecTauxmarge = :bipDecTauxmarge"),
    ..
     
    public class Article implements Serializable {
        private static final long serialVersionUID = 1L;
        @Id
        @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "article_seq")
        @SequenceGenerator(name = "article_seq", sequenceName = "article_art_int_id_seq", allocationSize = 1)
    ..
        @Basic(optional = false)
        @Column(name = "art_int_id")
        private Integer artIntId;
    ..
    // ici pas de probleme, ça marche avec la donnée de la table article
    @Basic(optional = false)
        @Column(name = "art_dec_coefnum")
        private BigDecimal artDecCoefnum;
    // concerne la donnée de la table bilan qui est ignorée
    @Column(name = "bip_dec_tauxmarge")
       private BigDecimal bipDecTauxmarge;
    ..
      public Article() {
        }
        public Article(Integer artIntId) {
            this.artIntId = artIntId;
        }
    ..
     public Article(Integer artIntId,
                String artVchNom,
    ..
                BigDecimal artDecCoefnum,
                 BigDecimal bipDecTauxmarge,
    ..
        public Article(Integer artIntId,
    ..
                BigDecimal artDecCoefnum,
                 BigDecimal bipDecTauxmarge,
    ..
                Date artDateCreation) {
            this.artIntId = artIntId;
            this......
    // donnée table article
            this.artDecCoefnum = artDecCoefnum;
    // donnée table bilan
            this.bipDecTauxmarge = bipDecTauxmarge ;
        }
     // donnée table article 
      public Integer getArtIntId() {
            return artIntId;
        }
        public void setArtIntId(Integer artIntId) {
            this.artIntId = artIntId;
        }
    //donnée table bilan
        public Integer getBipIntId() {
            return bipIntId;
        }
        public void setBipIntId(Integer bipIntId) {
            this.bipIntId = bipIntId;
        }
    ..
    //donnée table article
        public BigDecimal getArtDecCoefnum() {
            return artDecCoefnumpopup;
        }
        public void setArtDecCoefnum(BigDecimal artDecCoefnum) {
            this.artDecCoefnum = artDecCoefnum;
        }
    //donnée table bilan
        public BigDecimal getBiptDecTauxmarge() {
            return bipDecTauxmarge;
       }
        public void setBipDecTauxmarge(BigDecimal bipDecTauxmarge) {
           this.bipDecTauxmarge = bipDecTauxmarge;
        }
    ..
    pouvez m'aider à comprendre, j'ai déjà fait mes autres codes (tag, action, form, xml,..) et je vais essayer de "re"visiter tout ça ensuite si mon erreur ne se situe pas là.

    Merci par avance. je débute
    dan

  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
    Ce qui se passe c'est que tu ne peux pas avoir 2 NamedQuery du même nom, même si les définitions sont dans 2 classes séparées.
    Les NamedQuery sont enregistrés dans la PersistenceUnit, d'où le message... sur le deuxième, il te dit juste qu'il a ignoré la définition puisqu'il l'a déjà enregistré.
    Si les 2 requêtes sont les mêmes, supprime la définition dans Article (ça ne t'empêchera pas d'utiliser ce nom de query)
    Si elles sont différentes, alors préfixe la requête dans ta classe Article par "Article" plutôt que "Bilan"
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    @NamedQuery(name = "Bilan.findByBipDecTauxmarge", query = "SELECT b FROM Bilan b WHERE b.bipDecTauxmarge = :bipDecTauxmarge"),
    
    devient
    @NamedQuery(name = "Article.findByBipDecTauxmarge", query = "SELECT b FROM Bilan b WHERE b.bipDecTauxmarge = :bipDecTauxmarge"),
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  3. #3
    Membre à l'essai
    Homme Profil pro
    R&D
    Inscrit en
    Décembre 2013
    Messages
    32
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : R&D
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2013
    Messages : 32
    Points : 16
    Points
    16
    Par défaut suite votre aide
    Bonjour,
    tout d'abord je vous remercie, je ne savais pas cela.

    Mais alors il faut aussi que je remplace "Bilan" par "Article" dans tout le @named .. Comme ceci ? :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    à la place de :
    @NamedQuery(name = "Bilan.findByBipDecTauxmarge", query = "SELECT b FROM Bilan b WHERE b.bipDecTauxmarge = :bipDecTauxmarge"),
    je dois pas faire cela aussi  :?:
    @NamedQuery(name = "Article.findByBipDecTauxmarge", query = "SELECT a FROM Article a WHERE a.bipDecTauxmarge = :bipDecTauxmarge"),
    Ça concerne cela aussi le class Article, je dois enlever ce qui est raturé dans le code ci-dessous puisque cela est déjà codé dans bilan.java, ou je ne change rien ? :
    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
    public class Article implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "article_seq")
    @SequenceGenerator(name = "article_seq", sequenceName = "article_art_int_id_seq", allocationSize = 1)
    @Basic(optional = false)
    @Column(name = "art_int_id")
    private Integer artIntId;
    ..
    @Basic(optional = false)
    @Column(name = "art_dec_coefnum")
    private BigDecimal artDecCoefnum;
     
    <s>@Column(name = "bip_dec_tauxmarge_surheure")
    private BigDecimal bipDecTauxmargeSurheure;:?</s>
    ..
    public Article() {}
    public Article(Integer artIntId) { this.artIntId = artIntId;}
    ..
    public Article(Integer artIntId,
    ..
    BigDecimal artDecCoefnum,
    <s>BigDecimal bipDecTauxmargeSurheure,:?</s>
    ..
    public Integer getArtIntId() {
    return artIntId;
    }
    ..
    public void setArtIntId(Integer artIntId) {
    this.artIntId = artIntId;
    }
    ..
    public BigDecimal getArtDecCoefnum() {
    return artDecCoefnum;
    }
    public void setArtDecCoefnum(BigDecimal artDecCoefnum) {
    this.artDecCoefnum = artDecCoefnum;
    }
    ..
    <s>public BigDecimal getBiptDecTauxmargeSurheure() {:?
    return bipDecTauxmargeSurheure;
    }
    public void setBipDecTauxmargeSurheure(BigDecimal bipDecTauxmargeSurheure) {
    this.bipDecTauxmargeSurheure = bipDecTauxmargeSurheure;
    }</s>
    ..
    @Override
    public int hashCode() {
     int hash = 0;
    hash += (artIntId != null ? artIntId.hashCode() : 0);
    return hash;
    }
    @Override
    public boolean equals(Object object) {
    if (!(object instanceof Article)) {
    return false;
    }
    Article other = (Article) object;
    if ((this.artIntId == null && other.artIntId != null) || (this.artIntId != null && !this.artIntId.equals(other.artIntId))) {
    return false;
     }
    return true;
    }
    @Override
    public String toString() {
     return "jpa.Article[artIntId=" + artIntId + "]";
    }
    }
    Une autre question me vient à l'esprit, dans la validation.xml (ci-dessous), je peux donc mettre ce que je veux en "field property" ( property=tauxmargeanalytique"), celui-ci étant ensuite utilisé dans mon jsp article ?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    <field property="tauxmargeanalytique"
    depends="required">
    <arg key="errors.bipDecTauxmarge"/>
    </field>
    merci encore de vos explications qui me sont vraiment bien utiles
    dan

  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
    Citation Envoyé par danbreizh Voir le message
    Bonjour,
    tout d'abord je vous remercie, je ne savais pas cela.

    Mais alors il faut aussi que je remplace "Bilan" par "Article" dans tout le @named .. Comme ceci ? :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    à la place de :
    @NamedQuery(name = "Bilan.findByBipDecTauxmarge", query = "SELECT b FROM Bilan b WHERE b.bipDecTauxmarge = :bipDecTauxmarge"),
    je dois pas faire cela aussi  :?:
    @NamedQuery(name = "Article.findByBipDecTauxmarge", query = "SELECT a FROM Article a WHERE a.bipDecTauxmarge = :bipDecTauxmarge"),
    Oui, comme les requêtes sont différentes, il faut un nom différent

    Citation Envoyé par danbreizh Voir le message
    Ça concerne cela aussi le class Article, je dois enlever ce qui est raturé dans le code ci-dessous puisque cela est déjà codé dans bilan.java, ou je ne change rien ? :
    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
    public class Article implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "article_seq")
    @SequenceGenerator(name = "article_seq", sequenceName = "article_art_int_id_seq", allocationSize = 1)
    @Basic(optional = false)
    @Column(name = "art_int_id")
    private Integer artIntId;
    ..
    @Basic(optional = false)
    @Column(name = "art_dec_coefnum")
    private BigDecimal artDecCoefnum;
     
    <s>@Column(name = "bip_dec_tauxmarge_surheure")
    private BigDecimal bipDecTauxmargeSurheure;:?</s>
    ..
    public Article() {}
    public Article(Integer artIntId) { this.artIntId = artIntId;}
    ..
    public Article(Integer artIntId,
    ..
    BigDecimal artDecCoefnum,
    <s>BigDecimal bipDecTauxmargeSurheure,:?</s>
    ..
    public Integer getArtIntId() {
    return artIntId;
    }
    ..
    public void setArtIntId(Integer artIntId) {
    this.artIntId = artIntId;
    }
    ..
    public BigDecimal getArtDecCoefnum() {
    return artDecCoefnum;
    }
    public void setArtDecCoefnum(BigDecimal artDecCoefnum) {
    this.artDecCoefnum = artDecCoefnum;
    }
    ..
    <s>public BigDecimal getBiptDecTauxmargeSurheure() {:?
    return bipDecTauxmargeSurheure;
    }
    public void setBipDecTauxmargeSurheure(BigDecimal bipDecTauxmargeSurheure) {
    this.bipDecTauxmargeSurheure = bipDecTauxmargeSurheure;
    }</s>
    ..
    @Override
    public int hashCode() {
     int hash = 0;
    hash += (artIntId != null ? artIntId.hashCode() : 0);
    return hash;
    }
    @Override
    public boolean equals(Object object) {
    if (!(object instanceof Article)) {
    return false;
    }
    Article other = (Article) object;
    if ((this.artIntId == null && other.artIntId != null) || (this.artIntId != null && !this.artIntId.equals(other.artIntId))) {
    return false;
     }
    return true;
    }
    @Override
    public String toString() {
     return "jpa.Article[artIntId=" + artIntId + "]";
    }
    }
    Non, là, on est dans le mapping d'une entité, on fait le lien entre un attribut d'une classe java avec une colonne de base de données

    Citation Envoyé par danbreizh Voir le message
    Une autre question me vient à l'esprit, dans la validation.xml (ci-dessous), je peux donc mettre ce que je veux en "field property" ( property=tauxmargeanalytique"), celui-ci étant ensuite utilisé dans mon jsp article ?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    <field property="tauxmargeanalytique"
    depends="required">
    <arg key="errors.bipDecTauxmarge"/>
    </field>
    merci encore de vos explications qui me sont vraiment bien utiles
    dan
    Là, je ne sais pas, je n'utilise pas le framework validator mais des contrôles par EJB
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  5. #5
    Membre à l'essai
    Homme Profil pro
    R&D
    Inscrit en
    Décembre 2013
    Messages
    32
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : R&D
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2013
    Messages : 32
    Points : 16
    Points
    16
    Par défaut Je continue, j'espére ne pas abuser..
    Bonjour,

    Merci pour vos explications, elles sont simples mais bien compréhensibles.

    Tout cela me conduit vers mon createAction & actionForm, après ma validation.xml, ce je voudrais comprendre :
    Dans ArticleAction & dans ArticleForm, est ce que je dois faire un import ou struts fait le lien directement entre Article et Bilan ? (en gras dans le code ci dessous), la validation de mes champs JSP étant déjà réalisé par validation.xml.

    Voila comment je procède,

    1/ Je valide mon form avec validation.xml
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    <form name="CreateArticleForm">
    ..       
    <field property="coefnum" <!-- property JSP ARTICLE -->
    depends="required">
    <arg key="errors.artDecCoefnum"/> <!-- table Article -->
    </field>
    ..
    <field property="tauxmarge" <!-- property JSP ARTICLE-->
    depends="required">
    <arg key="errors.bip.DecTauxmarge"/> <!-- table Bilan -->
    </field>
    ..

    2 / puis mon Action
    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
    package action.xxx.approvisionnement.articles;
    import ejb.connection.RelaisEjb;
    import form.xxx.approvisionnement.articles.CreateArticleForm;
    import java.io.PrintStream;
    import java.math.BigDecimal;
    import java.math.RoundingMode;
    import java.util.List;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    import jpa.Article;
    // QUESTION , je dois importer Bilan, si oui, pourquoi ?
    import jpa.Bilan;
    import jpa.Fournisseur;
    ..
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.action.ActionMessage;
    import org.apache.struts.action.ActionMessages;
    import service.xxx.approvisionnement.articles.GestionArticlesRemote;
    
    public class CreateArticleAction extends Action {
    private static final String SUCCESS = "success";
    private static final String LOGIN = "login";
    
    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    if(request.getSession().getAttribute("logged") != null) {
    System.out.println("Enregistrement de l'article ");
    RelaisEjb leRelais = new RelaisEjb();
    GestionArticlesRemote remote = (GestionArticlesRemote)leRelais.getRemote("java:comp/env/GestionArticlesBean");
    CreateArticleForm f = (CreateArticleForm)form;
    
    if(remote.checkUniqueArticle(Integer.parseInt(f.getIdFournisseur()), f.getReference())) {
    Article art = new Article();
    art.setArtVchNom(f.getDesignation());
    ...
    if(f.getCoefnum().length() > 0) { // entité Article  & lien property validation.xml
    BigDecimal txcoefnum = new BigDecimal(f.getCoefnum()).setScale(2, RoundingMode.HALF_DOWN);
    art.setArtDecCoefnum(txcoefnum);
    }
    ..
    if(f.getTauxmarge() != null) { // entité Bilan & lien property validation.xml
    BigDecimal txmarge = new BigDecimal(f.getTauxmarge()).setScale(2, RoundingMode.HALF_DOWN);
    art.setBipDecTauxmarge(txmarge);
    }
    ..
    return mapping.findForward("login");
    ..


    3 / et mon Form
    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
    package form.xxx.approvisionnement.articles;
    ..
    import jpa.Article;
    // QUESTION , je dois importer Bilan comme mon JPA Fournisseur(liste) ?
    import jpa.Bilan;
    ..
    import jpa.Fournisseur;
    ..
    public class CreateArticleForm extends ActionForm {
    private String idFournisseur;
    ..
    private String coefnum; <!-- validation.xml OK-->
    
    private String tauxmarge; <!-- validation.xml OK-->
    ..
    public String getIdArticle() {
    return this.idArticle;
    }
    .. 
    public String getCoefnum() { // mon coef Table ARTICLE >> suite validation.xml
     return this.coefnum;
    }
    public void setCoefnum(String coefnum) {
    this.coefnum = coefnum;
    }
    ..
    public String getTauxmarge() { // ma donnée table BILAN >>  suite validation.xml
    return this.tauxmarge;
    }
    public void setTauxmarge(String tauxmarge) {
    this.tauxmarge = tauxmarge;
    }
    Je vous remercie, une fois que j'en aurai compris le principe de ce codage, je pourrai faire les autres.
    Struts est puissant, il faut juste tout comprendre en même temps, sinon..., ce qui fait que sur les forums ça "tourne' très rapidement à des complications qui se surajoutent les unes aux autres
    dan

  6. #6
    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
    Si tu dois faire les imports ? Je ne comprends pas la question...

    A la louche, et dans le doute, je dirais oui si tu utilises la classe, sinon, non...
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  7. #7
    Membre à l'essai
    Homme Profil pro
    R&D
    Inscrit en
    Décembre 2013
    Messages
    32
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : R&D
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2013
    Messages : 32
    Points : 16
    Points
    16
    Par défaut comment mon article.java peut savoir dans quelle table trouver ma donnée ?
    Pour les import, cela vient du fait que je me demande comment mon JPA Article peut chercher ma donnée bip_dec_tauxmarge dans la table puisqu'il Bilan qu'il ne la connaît pas ?

    Glassfish me dit "does not exist" ci-dessous, ce qui confirmerai (?) qu'il ne trouve pas ma table Bilan avant d'extraire ma donné bip...
    Avant c'était .. already exist, maintenant c'est "does not exist", La réponse est probablement "toute bête" mais le ne la sais pas.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Internal Exception: org.postgresql.util.PSQLException: ERROR: column t0.bip_dec_tauxmarge does not exist
    SI je vais à l'envers, je repars de la property de mon JSP, qui utilise la champ property de validation.xml, property qui se rapporte à une donnée de la table bilan (inconnue ? does not exist)... d’où le plantage de mon JSP ?
    Mon validation.xml
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    <field property="tauxmargeanalytique" // utilisée dans mon JSP (HTML)
    depends="required">
    <arg key="errors.bip.DecTauxmarge"/>
     </field>
    Donc je remonte vers mon code JPA , ( code ci-dessous) :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    // Ça c'est Ok
    @NamedQuery(name = "Article.findByArtDecCoefnum", query = "SELECT a FROM Article a WHERE a.artDecCoefnum = :artDecCoefnum"),
    // Par contre ici comment faire savoir que BipDecTauxmarge est dans la table Bilan de psql ?
    (bip_dec_tauxmarge étant une colonne de ma table bilan)
    @NamedQuery(name = "Article.findByBipDecTauxmarge", query = "SELECT a FROM Article a WHERE a.bipDecTauxmarge = :bipDecTauxmarge"),

    [B].... comment est trouvée la donnée "bip_dec_tauxmarge" >> psql/table Bilan (ci dessous)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    @Basic(optional = false)
    @Column(name = "bip_dec_tauxmarge")
    private BigDecimal bipDecTauxmarge;

    Je vous note mes codes pour information, ce sera peut être plus facile pour m'expliquer ce que je ne sais pas faire.
    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 class Article implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "article_seq")
    @SequenceGenerator(name = "article_seq", sequenceName = "article_art_int_id_seq", allocationSize = 1)
    @Basic(optional = false)
    @Column(name = "art_int_id")
    private Integer artIntId;
    
    // OK CLASS ARTICLE :)
    @Basic(optional = false)
    @Column(name = "art_dec_coefnum")
    private BigDecimal artDecCoefnum;
    
    // CLASS Bilan ?? :oops:
    @Basic(optional = false)
    @Column(name = "bip_dec_tauxmarge_surheure")
    private BigDecimal bipDecTauxmargeSurheure;

    suite JPA Classarticle
    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
    public Article() {}
    
    public Article(Integer artIntId) {
    this.artIntId = artIntId;}
    
    public Article(Integer artIntId,
    ...
    BigDecimal artDecCoefnum,
    BigDecimal bipDecTauxmarge,:oops:
    ..
    Date artDateCreation) {
    this.artIntId = artIntId;
    this.artVch...
    ..
    this.artDecCoefnum = artDecCoefnum;
    this.bipDecTauxmarge = bipDecTauxmarge ;:oops:
    ....
    }
    
    public Integer getArtIntId() {
    return artIntId;}
    
    public void setArtIntId(Integer artIntId) {
    this.artIntId = artIntId;}
    ...
    public BigDecimal getArtDecCoefnum() {
    return artDecCoefnumchute;
    }
    public void setArtDecCoefnum(BigDecimal artDecCoefnum) {
    this.artDecCoefnum = artDecCoefnum;
    }
    
    public BigDecimal getBipDecTauxmarge() {
    return bipDecTauxmarge;
    }:oops:
    public void setBipDecTauxmarge(BigDecimal  bipDecTauxmarge) {
    this. bipDecTauxmarge =  bipDecTauxmarge;
    }:oops:
    ..
    @Override
    public int hashCode() {
    int hash = 0;
    hash += (artIntId != null ? artIntId.hashCode() : 0);
    return hash;
    }
    
    @Override
    public boolean equals(Object object) {
    // TODO: Warning - this method won't work in the case the id fields are not set
    if (!(object instanceof Article)) {
     return false;
    }
    Article other = (Article) object;
    if ((this.artIntId == null && other.artIntId != null) || (this.artIntId != null && !this.artIntId.equals(other.artIntId))) {
    return false;
    }
    return true;
    }
    
    @Override
    public String toString() {
    return "jpa.Article[artIntId=" + artIntId + "]";
    }
    ..
    C'est pour ça que je me demandais si il ne fallait pas importer la classBilan
    Je patauge

    Merci encore
    dan

  8. #8
    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 danbreizh Voir le message
    Je patauge
    Je crois que c'est clair et je ne suis pas sûr de comprendre ce que tu cherches à faire au juste
    Tu as l'air de confondre un peu tout, ou de tout mélanger... il faudrait que tu sois plus précis sur ce que tu cherches à faire.

    Quelques explications sur l'ORM en général :

    L'entity est une réprésentation objet d'un enregistrement de base de données, avec ou non des relations vers cet objet.
    Toutes les propriétés de l'entity sont "mappées" vers une colonne de base de données ou vers une autre entity représentant une relation entre l'objet A et un objet B
    Ces relations peuvent être de 2 types (en gros) :
    - 1 vers 1
    - 1 vers plusieurs (avec un cas particulier en passant par une table de relation)

    Prenons 2 tables liées pour l'exemple : Article et Stock
    Le stock est en relation avec l'article et inversement. On peut mapper dans l'entity Stock une entity Article (généralement ManyToOne), inversement, l'article sera présent dans plusieurs stocks, on aura un Set<Stock> dans l'entity Article (généralement OneToMany)
    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
     
    class Stock
    {
       private Integer id;
       private String designation;
       private Long quantite;
       private Article article;
       ...
    }
     
    class Article
    {
       private Integer id;
       private String designation;
       private Set<Stock> stocks;
       ...
    }
    Donc, si on liste des Articles, on peut accéder à des informations de Stock via le set "stocks"
    De même, si on liste des Stocks, on peut accéder aux informations de l'Article via "article"
    Pour les requêtes, on peut également s'en servir.
    Pour lister tous les stocks d'un article, on ferait une requête de ce type
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    entityManager.createQuery("select s from Stock s where s.article = :monArticle");
    Bref, c'est à la fois simple et compliqué mais il faudrait que tu suives un tuto sur le sujet
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  9. #9
    Membre à l'essai
    Homme Profil pro
    R&D
    Inscrit en
    Décembre 2013
    Messages
    32
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : R&D
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2013
    Messages : 32
    Points : 16
    Points
    16
    Par défaut suite Ignoring the @NamedQuery [xx] specified on class [jpa.Article] since a query with that name already exi
    Bonjour,

    je suis désolé de revenir, mais je n'y arrive pas.
    Puis je vous mettre tout mes codes (xml, actio, form, tag, JSP ,..) pour que vous y jetiez un oeil et me guider en m'expliquant pas à pas pour que j'entegistre, je dois avoir un problème aussi ailleurs.
    Si vous ne pouviez pas m'aider je le comprendrai, j'ai peu de tutoriels struts en français ( c'est une appli que je dois reprendre derrière quelqu'un d'autre)....

    Merci de votre aide et de votre éventuel futur concours
    Dan

  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
    Tu peux toujours le mettre, si ce n'est pas moi qui le traite, ce sera un autre
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  11. #11
    Membre à l'essai
    Homme Profil pro
    R&D
    Inscrit en
    Décembre 2013
    Messages
    32
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : R&D
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2013
    Messages : 32
    Points : 16
    Points
    16
    Par défaut Je reprends tout a zéro, voici mon JPA So c'est OK je met mon form et mon action
    Je te remercie, mais si c'était toi je préférerai, tes explicatiions sont claires, presque pédagogiques, maintenant si une autre bonne âme peut m'aider je ne la refuserai pas bienb sûr

    Donc je reprends mes codes modifiés ci dessous :
    package jpa;

    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
    import java.io.Serializable;
    import java.math.BigDecimal;
    import java.util.Collection;
    import java.util.Date;
    import javax.persistence.Basic;
    import javax.persistence.CascadeType;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.FetchType;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.JoinColumn;
    import javax.persistence.ManyToOne;
    import javax.persistence.NamedQueries;
    import javax.persistence.NamedQuery;
    import javax.persistence.OneToMany;
    import javax.persistence.SequenceGenerator;
    import javax.persistence.Table;
    import javax.persistence.Temporal;
    import javax.persistence.TemporalType;
     
    /**
     * @author XXXXX
     */
    @Entity
    @Table(name = "article", catalog = "xxx", schema = "public")
    @NamedQueries({@NamedQuery(name = "Article.findAll", query = "SELECT a FROM Article a"),
    @NamedQuery(name = "Article.findByArtIntId", query = "SELECT a FROM Article a WHERE a.artIntId = :artIntId"),
    ....
    // ma table Bilan "ignorée"
    à la place de :
    @NamedQuery(name = "Bilan.findByBipDecTauxmarge", query = "SELECT b FROM Bilan b WHERE b.bipDecTauxmarge = :bipDecTauxmarge"),
    j'ai corrigé comme ci dessous  :?:
    @NamedQuery(name = "Article.findByBipDecTauxmarge", query = "SELECT a FROM Article a WHERE b.bipDecTauxmarge = :bipDecTauxmarge"),
    ..
    
    public class Article implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "article_seq")
    @SequenceGenerator(name = "article_seq", sequenceName = "article_art_int_id_seq", allocationSize = 1)
    ..
    @Basic(optional = false)
    @Column(name = "art_int_id")
    private Integer artIntId;
    ..
    // concerne la donnée lien de la table psql bilan colonne taux marge
    @Basic(optional = false)
    @Column(name = "bip_dec_tauxmarge")
    private BigDecimal bipDecTauxmarge;
    ...
    
    
    public Article() {
    }
    public Article(Integer artIntId) {
    this.artIntId = artIntId;
    }
    ..
    // donnée psql table bilan
    BigDecimal bipDecTauxmarge,
    ..
    
    // donnée psql table bilan
    public Article(Integer artIntId,
    ..
    // donnée psql table bilan
    BigDecimal bipDecTauxmarge,
    ..
    Date artDateCreation) {
    this.artIntId = artIntId;
    ..
    // donnée psql table bilan >> Netbeans m'indique : " cannot find symbol; symbole variable bipDecTauxmarge; location class jpa.Article <<
    this.bipDecTauxmarge = bipDecTauxmarge ;
    }
    ..
    
    
    
    public Integer getBipIntId() {
    return bipIntId;
    }
    public void setBipIntId(Integer bipIntId) {
    this.bipIntId = bipIntId;
    }
    ..
    //donnée table bilan
    public BigDecimal getBiptDecTauxmarge() {
    return bipDecTauxmarge;
    }
    public void setBipDecTauxmarge(BigDecimal bipDecTauxmarge) {
    this.bipDecTauxmarge = bipDecTauxmarge;
    }
    ..

  12. #12
    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
    Là je ne comprends pas trop, tout est mélangé, je préfèrerais avoir les sources complets et séparés.

    Ce que j'ai remarqué, c'est que le namedQuery a une erreur
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    @NamedQuery(name = "Article.findByBipDecTauxmarge", query = "SELECT a FROM Article a WHERE b.bipDecTauxmarge = :bipDecTauxmarge")
    Aucune table n'est préfixée par "b"
    La colonne bipDecTauxmarge est dans la table Article ?
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  13. #13
    Membre à l'essai
    Homme Profil pro
    R&D
    Inscrit en
    Décembre 2013
    Messages
    32
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : R&D
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2013
    Messages : 32
    Points : 16
    Points
    16
    Par défaut suite
    Merci de me répondre

    Pour le b c'est OK, j'ai corrigé

    je vais faire le nécessaire proprement ce soir pour mettre tout mes codes complets.
    Mais tous les codes, cela veut dire tout les codes JPA.JSP.TAG, FORM, etc ou simplement le code JPA.
    Auriez vous un tuto struts débutant/base (méthodologie) en francais ( liens), j'en ai enregistrés qquns mais partiels ou incomplets et souvent déjà réservé à des initiés.
    Je vais essayer de "potasser" ce W.End
    Dan

    Ps : j'ai été trop vite et n'ai pas lu votre message jusq'au bout ..
    La colonne bipDecTauxmarge est dan une autre table nommée bilan (bip)

  14. #14
    Membre à l'essai
    Homme Profil pro
    R&D
    Inscrit en
    Décembre 2013
    Messages
    32
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : R&D
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2013
    Messages : 32
    Points : 16
    Points
    16
    Par défaut
    Voila mon JPA mis à jour (cette fois j'ai mis les dénominations réelles exemple coefchutenum à la place de coefchute)
    J'ai enlevé tous les codes qui ne sont pas impliqués dans ma demande, ce serait trés trés long...

    Table psql Article (Art)
    ex : Article.findByArtDecCoefnumchutearticlepopup
    Table psql Bilan (Bip) de laquelle je souhaite extraire une donnée de calcul à afficher dans mon jsp, et puis à utiliser ensuite dans un calcul Javascript (tag), en l'occurence il s'agit de la donnée de la table bilan / colonne BipDecTauxmargeSurheure
    ex : Article.findByBipDecTauxmargeSurheure

    Avec des données de la même table tout baigne (même processus), mais en croisant des données de table différentes je "bouine" complétement

    Colonnes psql:
    Dec= colonne numeric
    Vch= colonne charracter varying
    Int= colonne Intéger

    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
    package jpa;
    import java.io.Serializable;
    import java.math.BigDecimal;
    import java.util.Collection;
    import java.util.Date;
    import javax.persistence.Basic;
    import javax.persistence.CascadeType;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.FetchType;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.JoinColumn;
    import javax.persistence.ManyToOne;
    import javax.persistence.NamedQueries;
    import javax.persistence.NamedQuery;
    import javax.persistence.OneToMany;
    import javax.persistence.SequenceGenerator;
    import javax.persistence.Table;
    import javax.persistence.Temporal;
    import javax.persistence.TemporalType;
    
    @Entity // ***********************************ENTITY
    @Table(name = "article", catalog = "artisance", schema = "public")
    @NamedQueries({@NamedQuery(name = "Article.findAll", query = "SELECT a FROM Article a"),
    @NamedQuery(name = "Article.findByArtIntId", query = "SELECT a FROM Article a WHERE a.artIntId = :artIntId"),
    @NamedQuery(name = "Article.findByArtVch...", query = "SELECT a FROM Article a WHERE a.artVch... = :artVch..."),
    ...
    @NamedQuery(name = "Article.findByArtDecCoefnumchutearticlepopup", query = "SELECT a FROM Article a WHERE a.artDecCoefnumchutearticlepopup = :artDecCoefnumchutearticlepopup"),
    @NamedQuery(name = "Article.findByBipDecTauxmargeSurheure", query = "SELECT a FROM Article a WHERE a.bipDecTauxmargeSurheure = :bipDecTauxmargeSurheure"),
    ....
    @NamedQuery(name = "Article.findByArtDateCreation", query = "SELECT a FROM Article a WHERE a.artDateCreation = :artDateCreation"),
    @NamedQuery(name = "Article.findByArtDateModification", query = "SELECT a FROM Article a WHERE a.artDateModification = :artDateModification")})
    
    public class Article implements Serializable {// ***********************************public class Article
        private static final long serialVersionUID = 1L;
        @Id
        @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "article_seq")
        @SequenceGenerator(name = "article_seq", sequenceName = "article_art_int_id_seq", allocationSize = 1)
    
        @Basic(optional = false)
        @Column(name = "art_int_id")
        private Integer artIntId;
    
    // ajout coef chute 18 02 2015
        @Basic(optional = false)
        @Column(name = "art_dec_coefnumchutearticlepopup")
        private BigDecimal artDecCoefnumchutearticlepopup;
    // fin ajout
    
    // ajout/modif 09 04 2015 MAP TABLE BILAN (BIP) *******public class Article**********
    @Basic(optional = false)
    @Column(name = "bip_dec_tauxmarge_surheure")
          private BigDecimal bipDecTauxmargeSurheure;
    // FIN AJOUT ***********
    
        @Basic(optional = false)
        @Column(name = "art_date_creation")
        @Temporal(TemporalType.DATE)
        private Date artDateCreation;
    
        @Column(name = "art_date_modification")
        @Temporal(TemporalType.DATE)
        private Date artDateModification;
    
        @OneToMany(cascade = CascadeType.ALL, mappedBy = "artIntId", fetch = FetchType.LAZY)
        private Collection<Ldarticle> ldarticleCollection;
    
        @JoinColumn(name = "fam_int_id", referencedColumnName = "fam_int_id")
        @ManyToOne(optional = false, fetch = FetchType.LAZY)
        private Reffamillearticle famIntId;
    
        @OneToMany(cascade = CascadeType.ALL, mappedBy = "article", fetch = FetchType.LAZY)
        private Collection<ArticlecatalogueHasArticle> articlecatalogueHasArticleCollection;
    
        @OneToMany(cascade = CascadeType.ALL, mappedBy = "artIntId", fetch = FetchType.LAZY)
        private Collection<Commandearticle> commandearticleCollection;
    
        public Article() { 
        }
    
        public Article(Integer artIntId) {// ***********************************publicArticle
            this.artIntId = artIntId;
        }
    
    public Article(Integer artIntId,// ***********************************public Article (Integer artIntId,
    String artVch...,
    ...
    BigDecimal artDecCoefnumchutearticlepopup,
    BigDecimal bipDecTauxmargeSurheure,
    Date artDateCreation) {
    this.artIntId = artIntId;
    this.artVch... = artVch...
    this.artDateCreation = artDateCreation;
    this.artDecCoefnumchutearticlepopup = artDecCoefnumchutearticlepopup;
    this.BipDecTauxmargeSurheure = BipDecTauxmargeSurheure;
    }
    
    public Integer getArtIntId() {
    return artIntId;
    }
    public void setArtIntId(Integer artIntId) {
     this.artIntId = artIntId;
        }
    
    public String getArtVch...() {
    return artVch...;
    }
    public void setArtVch...(String artVch...) {
    this.artVchN... = artVch...;
        }
    
    public BigDecimal getArtDecCoefnumchutearticlepopup() {
    return artDecCoefnumchutearticlepopup;
    }
    public void setArtDecCoefnumchutearticlepopup(BigDecimal artDecCoefnumchutearticlepopup) {
    this.artDecCoefnumchutearticlepopup = artDecCoefnumchutearticlepopup;
    }
    
    // ajout 09 04 2015
    public BigDecimal getBiptDecTauxmargeSurheure() {
    return bipDecTauxmargeSurheure;
    }
    public void setBipDecTauxmargeSurheure(BigDecimal bipDecTauxmargeSurheure) {
    this.bipDecTauxmargeSurheure = bipDecTauxmargeSurheure;
    }
    
        public Date getArtDateCreation() {
            return artDateCreation;
        }
        public void setArtDateCreation(Date artDateCreation) {
            this.artDateCreation = artDateCreation;
        }
    
        public Date getArtDateModification() {
            return artDateModification;
        }
        public void setArtDateModification(Date artDateModification) {
            this.artDateModification = artDateModification;
        }
    
        public Collection<Posteconsommablearticle> getPosteconsommablearticleCollection() {
            return posteconsommablearticleCollection;
        }
        public void setPosteconsommablearticleCollection(Collection<Posteconsommablearticle> posteconsommablearticleCollection) {
            this.posteconsommablearticleCollection = posteconsommablearticleCollection;
        }
    
        public Collection<Ldarticle> getLdarticleCollection() {
            return ldarticleCollection;
        }
        public void setLdarticleCollection(Collection<Ldarticle> ldarticleCollection) {
            this.ldarticleCollection = ldarticleCollection;
        }
    
    
        public Collection<ArticlecatalogueHasArticle> getArticlecatalogueHasArticleCollection() {
            return articlecatalogueHasArticleCollection;
        }
        public void setArticlecatalogueHasArticleCollection(Collection<ArticlecatalogueHasArticle> articlecatalogueHasArticleCollection) {
            this.articlecatalogueHasArticleCollection = articlecatalogueHasArticleCollection;
        }
    
    ....
        public Collection<Commandearticle> getCommandearticleCollection() {
            return commandearticleCollection;
        }
        public void setCommandearticleCollection(Collection<Commandearticle> commandearticleCollection) {
            this.commandearticleCollection = commandearticleCollection;
        }
    
    
        @Override
        public int hashCode() {
            int hash = 0;
            hash += (artIntId != null ? artIntId.hashCode() : 0);
            return hash;
        }
    
        @Override
        public boolean equals(Object object) {
            // TODO: Warning - this method won't work in the case the id fields are not set
            if (!(object instanceof Article)) {
                return false;
            }
            Article other = (Article) object;
            if ((this.artIntId == null && other.artIntId != null) || (this.artIntId != null && !this.artIntId.equals(other.artIntId))) {
                return false;
            }
            return true;
        }
    
        @Override
        public String toString() {
            return "jpa.Article[artIntId=" + artIntId + "]";
        }
    
    }

  15. #15
    Membre à l'essai
    Homme Profil pro
    R&D
    Inscrit en
    Décembre 2013
    Messages
    32
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : R&D
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2013
    Messages : 32
    Points : 16
    Points
    16
    Par défaut suite
    bonjour,

    j'ai besoin de votre aide, pouvez vous m’accompagner, je ne m'en sort pas.
    merci
    daniel

  16. #16
    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
    Comme on ne connait pas la structure de tes tables et surtout les relations entre elles, c'est difficile de t'aider.
    Si tu as une relation 1-1 entre Article et Bilan tu peux faire une jonction via le mapping d'article en mappant l'entité Bilan dans l'entité Article
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    ... select a from Article a join fetch a.bilan where a.ce_qui_me_permet_d'identifier_article = ? ...
    Si tu as une relation 1-n et si tu as le moyen d'identifier l'enregistrement unique de bilan pour ta demande, tu peux faire l'inverse, mapper Article dans Bilan et récupérer l'information par le bilan
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    ... select b from Bilan b join fetch b.article where b.ce_qui_me_permet_d'identifier_bilan = ? ...
    A l'arriver, tu as les informations des 2 tables
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  17. #17
    Membre à l'essai
    Homme Profil pro
    R&D
    Inscrit en
    Décembre 2013
    Messages
    32
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : R&D
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2013
    Messages : 32
    Points : 16
    Points
    16
    Par défaut suite
    je vais essayer comme cela.
    je n'ai pas de relation entre mes 2 tables
    Merci

  18. #18
    Membre à l'essai
    Homme Profil pro
    R&D
    Inscrit en
    Décembre 2013
    Messages
    32
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : R&D
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2013
    Messages : 32
    Points : 16
    Points
    16
    Par défaut test
    je veux simplement recopier une valeur "tauxmarge" de la table bilan dans la table article "artDecCopieTauxmarge"

    Pour info voici l'entity de ma table bilan avec mon taux de marge (à copier dans article)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    @NamedQuery(name = "Bilan.findByBipDecTauxmarge", query = "SELECT b FROM Bilan b WHERE b.bipDecTauxmarge = :bipDecTauxmarge"),
    ..
    @Column(name = "bip_dec_tauxmarge")
     private BigDecimal bipDecTauxmarge;
    SI j'applique cela donne ceci dans entity article, je mappe ma table bilan dans ma table article c'est ça le code ?
    .. select a from Article a join fetch a.bilan where a.ce_qui_me_permet_d'identifier_article = ? ...
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    @NamedQuery(name = "Article.findByArtCopieTauxmarge", query = "SELECT a FROM Article a join fetch a.bilan WHERE a. Tauxmarge = :artDecCopieTauxmarge"), 
    ..
    @Basic(optional = false)
    @Column(name = "art_dec_copieTauxmarge")
    private BigDecimal artDecCopieTauxmarge; 
    ..
    J'approche ???

  19. #19
    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
    Pour faire simple :
    - soit tu copies effectivement la colonne dans ta table Article et tu la mappes simplement (il y aura une redondance mais bon...)
    - soit tu joins les 2 tables dans ton mapping

    Voici un exemple de jonction 1-1
    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
    public class Article
    {
        private Integer uid;
        private Bilan bilan;
        ...
     
        @Id
        @Column(name = "UID", unique = true, nullable = false)
        public Integer getUid()
        {
            return this.uid;
        }
     
        public void setUid(Integer uid)
        {
            this.uid = uid;
        }
     
        @ManyToOne(fetch = FetchType.LAZY)
        @JoinColumn(name = "UID_BILAN", nullable = false)
        public Bilan getBilan()
        {
            return this.bilan;
        }
     
        public void setBilan(Bilan bilan)
        {
            this.bilan = bilan;
        }
        ...
    }
    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
    public class Bilan
    {
        private Integer uid;
        ...
     
        @Id
        @Column(name = "UID", unique = true, nullable = false)
        public Integer getUid()
        {
            return this.uid;
        }
     
        public void setUid(Integer uid)
        {
            this.uid = uid;
        }
    }
    Dans cet exemple, on aurait physiquement une table article qui ressemblerait à ceci
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    CREATE TABLE ARTICLE (    
      UID INTEGER NOT NULL, 
      UID_BILAN INTEGER,
      ...
      PRIMARY KEY(UID)
    );
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  20. #20
    Membre à l'essai
    Homme Profil pro
    R&D
    Inscrit en
    Décembre 2013
    Messages
    32
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : R&D
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2013
    Messages : 32
    Points : 16
    Points
    16
    Par défaut Merci
    Bonjour,

    excuses moi de ne pas t'avoir remercié avant, j'ai juste oublié , mais ÇA MARCHE , il y a peu de temps, mais j'ai du passer sur autre chose (en train de me battre avec freechart et ma BD..)
    Merci encore et vraiment sincèrement de ton aide
    dan

Discussions similaires

  1. Réponses: 5
    Dernier message: 17/02/2013, 16h59
  2. Réponses: 2
    Dernier message: 16/07/2010, 10h04
  3. ORA-12154: TNS:Could not resolve the connect identifier specified
    Par dydy12 dans le forum Connexions aux bases de données
    Réponses: 0
    Dernier message: 02/01/2010, 09h32
  4. Réponses: 2
    Dernier message: 06/04/2009, 09h16
  5. (macosX,eclipse 3.4) classe JPA non trouvée pas un EJB
    Par olivier57b dans le forum Glassfish et Payara
    Réponses: 16
    Dernier message: 17/01/2009, 22h32

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