-->
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.  [ 1 post ] 
Author Message
 Post subject: Mapping de collection et paramètre additionnel
PostPosted: Mon Dec 17, 2007 2:42 am 
Newbie

Joined: Sun Dec 16, 2007 9:06 am
Posts: 1
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.1.3

Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.immo.bo.impl">
   <class name="Proprietaire" table="t_immo_proprietaire" lazy="true">
      <id name="tecid" unsaved-value="-1">
         <column name="TECID" length="20" />
         <generator class="identity" />
      </id>

      <version name="teclock" column="TECLOCK" type="java.util.Date" />

      <property name="nom" column="NOM" />

      <property name="prenom" column="PRENOM" />

      <!-- Un propriétaire peut avoir plusieurs adresses -->
      <set name="adresses" inverse="true" cascade="all" lazy="false">
         <key column="FK_PROPRIETAIRE_TECID"/>
         <one-to-many class="Adresse"/>
      </set>

      <!-- Un propriétaire peut avoir plusieurs lots un lot peut avoir plusieurs propriétaires -->
      <set name="lots" table="t_immo_proprietaire_lot" lazy="true" cascade="all">
         <key column="FK_PROPRIETAIRE_TECID" not-null="true" />
         <many-to-many class="Lot" column="FK_LOT_TECID" />
      </set>

   </class>
</hibernate-mapping>


Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.immo.bo.impl">
   <class name="Lot" table="t_immo_lot" lazy="true">
      <comment></comment>
      <id name="tecid" unsaved-value="-1">
         <column name="TECID" length="20" />
         <generator class="identity" />
      </id>

      <version name="teclock" column="TECLOCK" type="java.util.Date" />

      <!-- Un lot n'a qu'une unique adresse et inversement -->
      <one-to-one name="adresse" class="Adresse" />

      <!-- On peut avoir plusieurs lots du même type -->
      <many-to-one name="typeLot" class="TypeLot" column="FK_TYPE_TECID" not-null="true" unique="true" cascade="persist,merge,save-update" />
      
      <set name="proprietaires" table="t_immo_proprietaire_lot">
         <key column="FK_LOT_TECID" />
         <many-to-many column="FK_PROPRIETAIRE_TECID" class="Proprietaire" />
      </set>
   </class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close(): N/A

Full stack trace of any exception that occurs: N/A

Name and version of the database you are using: mysql 5.1

The generated SQL (show_sql=true): N/A

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html

Bonjour,

Je cherche à faire un mapping entre les deux classes précédentes :
un propriétaire peut avoir plusieurs lots et un lot peut appartenir à plusieurs propriétaires. Jusque là c'est simple, c'est le code que j'ai déjà. Par contre dans le cas où un lot appartient à plusieurs propriétaires il faut un autre paramètre pour savoir son nombre de parts, et ce paramètre doit être dans la table t_immo_proprietaire_lot.

Comment ajouter ce paramètre au mapping svp ?


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

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.