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!!!