-->
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.  [ 4 posts ] 
Author Message
 Post subject: .:: Mapping a Map
PostPosted: Thu Mar 25, 2004 11:54 am 
Beginner
Beginner

Joined: Tue Jan 27, 2004 8:25 am
Posts: 45
Hi all!
I'm trying to create a map, but I'm having some problems when compiling my hibernate mapping file.

Here are my classes:

Code:

public class ClientType
{
   private Long code;
   private String name;
   
   private Map tariffs;

// getters and setters....

}



this object will have an Map of tariffs as you can see, so these will be the classes regarding Tariffs:

Code:

public abstract class Tariff
{
   private ClientType clientType;
   private Calendar fromDate;
   private String name;
   private double markUp;
   
   private TariffID id;

// getters and setters...
}

public class TariffID implements Serializable
{
   private ClientType clientType;
   private Calendar fromDate;

// getters and setters, equals() and hashChode()
}


Now, what I'm trying to do to map this is:

Code:

<class name="es.agency.ClientType">
   <id name="code" type="long" column="code"  unsaved-value="null">
      <generator class="native"/>
   </id>
   <property name="name" type="string" length="40"/>
   <map name="tariffs" inverse="true" lazy="true" cascade="all">       
      <key column="clientType"/>
       <index column="fromDate" type="date"/>       
      <one-to-many class="es.tariff.Tariff"/>
   </map>
</class>


<class name="es.tariff.Tariff" discriminator-value="U">
    <composite-id name="id" class="es.tariff.TariffID">
       <key-many-to-one name="clientType" class="es.agency.ClientType" column="clientType"/>
       <key-property name="fromDate" type="date"/>
   </composite-id>
   <discriminator column="type" type="character" />
   <property name="name" type="string"/>
   <property name="markUp" type="double"/>   
   
   <subclass name="es.tariff.NetTariff"
       discriminator-value="N" dynamic-update="true"
       dynamic-insert="true">
    </subclass>
   
    <subclass name="es.tariff.CommissionableTariff"
       discriminator-value="C" dynamic-update="true"
       dynamic-insert="true">
       <property name="commission" type="double"/>
    </subclass>   
</class>



but when compiling I'm getting errors like:

Code:
0    [main] ERROR net.sf.hibernate.util.XMLHelper  - Error parsing XML: XML Inpu
tStream(306)
org.xml.sax.SAXParseException: The content of element type "map" must match "(me
ta*,jcs-cache?,key,(index|composite-index|index-many-to-many|index-many-to-any),
(element|one-to-many|many-to-many|composite-element|many-to-any))".


So how should I map the ClientType, so it can have a tariffs map?
Thank you very much in advance!!!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 25, 2004 6:58 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Try the xml parser provided in the Hibernate distro

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 26, 2004 4:58 am 
Beginner
Beginner

Joined: Tue Jan 27, 2004 8:25 am
Posts: 45
ok, but I just need to know the syntax for the <map></map> of tariffs, knowing that the primary key of a tariffs has two elements, which are a clientType and a date.
Thank's in advance!!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 26, 2004 3:25 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
It is the expected syntax.
The FK is a 1-column key (clientType).

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.