-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Probleme de composite-element
PostPosted: Wed Sep 14, 2005 9:53 am 
Newbie

Joined: Wed Aug 17, 2005 9:39 am
Posts: 5
Bonjour, je viens de débuter mon premier projet de tests avec hibernate 3.0.5. J'ai réussi à réaliser mes premiers pojos facilement.
Cependant j'ai un soucis pour récupérer certaines données.

J'ai une table outil qui contient un id et un numéro de reference. J'ai une table Composant qui contient un id et un numéro de reference également. Un outil peux avoir plusieurs composants. Pour cela j'ai créer une table intermédiaire qui conteint les ids de l'outil et du ou des composants.

Maintenant concernant la table intermediaire nommée ToolsComponents j'y ai ajouté des attributs du genre nombre de composants...
Donc ma table ToolsComponents contient Tc_Tools(Id outil),Tc_Comp (id composant),Tc_Quantite

Le probleme est que je ne sais comment faire pour aller rechercher ces données ???

Voici plus d'informations

Hibernate version: 3.0.5

Mapping documents:

Code:
<hibernate-mapping package="outil">

    <class name="Outil" table="Tools" lazy="true">
        <id name="id" column="To_Id">
            <generator class="increment"/>
        </id>
        <property name="t" column="To_T" type="string"/>
               
        <!--<set name="composants" table="ToolsComponents">
        <key column="Tc_Tools"/>
        <many-to-many column="Tc_Comp" class="Composant"/>
        </set>-->
       
        <set name="composants" table="ToolsComponents">
            <key column="Tc_Tools"/>
            <composite-element class="OutilComposant">
                <property name="quantity" column="Tc_Quantite "/>
                <many-to-one name="Composant" column="Tc_Comp" />
            </composite-element>
        </set>
    </class>
</hibernate-mapping>


Full stack trace of any exception that occurs:
org.hibernate.exception.SQLGrammarException: could not initialize a collection: [outil.Outil.composants#844]

Name and version of the database you are using: Mysql 5.0.10b

The generated SQL (show_sql=true):
Hibernate: select outil0_.To_Id as To1_0_, outil0_.To_T as To2_0_0_ from Tools outil0_ where outil0_.To_Id=?

Hibernate: select composants0_.Tc_Tools as Tc1_0_, composants0_.Tc_Quantite as Tc2_0_, composants0_.Tc_Comp as Tc3_0_ from ToolsComponents composants0_ where composants0_.Tc_Tools=?

Les classes :
Code:
public class OutilComposant {
    private int quantity;
    private Outil outil;
    private Composant composant;
 
    public OutilComposant() {
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public Outil getOutil() {
        return outil;
    }

    public void setOutil(Outil outil) {
        this.outil = outil;
    }

    public Composant getComposant() {
        return composant;
    }

    public void setComposant(Composant composant) {
        this.composant = composant;
    }

    public boolean equals(Object obj) {
        boolean retValue;
       
        retValue = super.equals(obj);
        return retValue;
    }

    public int hashCode() {
        int retValue;
       
        retValue = super.hashCode();
        return retValue;
    }


Code:
public class Outil {
   
    private int id;
    private String t;
    private Set composants = new HashSet();
   
    public Outil() {
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getT() {
        return t;
    }

    public void setT(String t) {
        this.t = t;
    }

    public Set getComposants() {
        return composants;
    }

    public void setComposants(Set composants) {
        this.composants = composants;
    }

    public boolean equals(Object obj) {
        boolean retValue;
       
        retValue = super.equals(obj);
        return retValue;
    }

    public int hashCode() {
        int retValue;
       
        retValue = super.hashCode();
        return retValue;
    }
}



Voyez vous d'ou pourrais venir le probleme ?

Merci de votre aide


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 14, 2005 10:13 am 
Newbie

Joined: Wed Aug 17, 2005 9:39 am
Posts: 5
j'ai résolu le probleme merci :)
Cestait le nom de ma talbe intermediraire qui n'etait pas correcte


Top
 Profile  
 
 Post subject: composite
PostPosted: Sun Sep 18, 2005 3:09 am 
Newbie

Joined: Fri Sep 16, 2005 1:44 pm
Posts: 10
Location: France (Paris)
Salut ,


J'ai quelques problemes avec les composites pas en affichage
mais en mise a jour.
As tu continuer ton test ou un autre avec des composites ?
si oui pourrais tu poster les différents fichiers ?

cela fait 4 jours que je suis sur un pb de cles composite et
je commence a desepérer.

Merci


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.