Hi there,
Using Hiberante 2.1.3
I have the following mappings
agenciesLocations.hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping package="gr.forthnet.openseas.models">
<class name="Location" table="agencies_cities_counties" polymorphism="explicit">
<id name="abbreviation" column="county_en" type="java.lang.String" unsaved-value="null" length="32">
<generator class="hilo"/>
</id>
<property name="name" column="county_gr_en" not-null="true"/>
<bag name="destinations" cascade="all" inverse="false" lazy="false">
<key column="county_en" />
<one-to-many class="Area" />
</bag>
</class>
<class name="Area" table="agencies_cities_counties">
<id name="abbreviation" column="city_en" type="java.lang.String" unsaved-value="null" length="32">
<generator class="hilo"/>
</id>
<property name="name" column="city_gr_en" not-null="true"/>
<many-to-one name="parent" class="Location" column="county_en" />
</class>
</hibernate-mapping>
locations.hbm.xmlCode:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping package="gr.forthnet.openseas.models">
<class name="Location" table="destinations" polymorphism="explicit">
<id name="abbreviation" column="dabbr" type="java.lang.String" unsaved-value="null" length="32">
<generator class="hilo"/>
</id>
<property name="name" column="dname" not-null="true"/>
<bag name="destinations" cascade="all" inverse="false" lazy="false">
<key column="dabbr" />
<one-to-many class="Area" />
</bag>
</class>
<class name="Area" table="areas">
<id name="abbreviation" column="aabbr" type="java.lang.String" unsaved-value="null" length="32">
<generator class="hilo"/>
</id>
<property name="name" column="aname" not-null="true"/>
<many-to-one name="parent" class="Location" column="dabbr" />
</class>
</hibernate-mapping>
Ofcourse I get a duplicate import error on this.
How can i make the above mappings and how do I distinguish them in HQL?
Thanks in advance