Hello,
I have a <map> that takes a composite key and a one-to-many value. The problem I am having is that I want the composite key properties to be placed into the table I specify for the <map> but they are instead being added to the table for the one-to-many mapped class.
Actually the table I specify in the <map> declaration is not created by the 'org.hibernate.tool.hbm2ddl.SchemaExport' tool.
I've used a <map> using a string key before and it generates the specified table correctly.
Thanks,
Kastor
Hibernate version:
3.0.5
Mapping documents:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-lazy="false"
>
<class
name=LocationHistoryTable"
table="locationhistorytable"
dynamic-update="true"
optimistic-lock="none"
batch-size="50"
>
<id
name="ID"
column="ID"
type="java.lang.Long"
unsaved-value="none"
>
<generator class="assigned"/>
</id>
<map
name="locationTable"
lazy="false"
cascade="save-update"
table="locationhistorytablemap"
>
<key column="fk_locationhistorytableid" />
<composite-map-key class=LocationElementKey" >
<key-property name="person" type="int" column="fk_locationelementkey_person" />
<key-property name="personLocation" type="int" column="fk_locationelementkey_personlocation" />
<key-property name="trip" type="int" column="fk_locationelementkey_trip" />
</composite-map-key>
<one-to-many class="LocationDataHistory" />
</map>
</class>
</hibernate-mapping>
Schema:
Code:
\d locationhistorytable
Table "public.locationhistorytable"
Column | Type | Modifiers
--------+--------+-----------
id | bigint | not null
Indexes:
"locationhistorytable_pkey" primary key, btree (id)
\d locationdatahistory
Table "public.locationdatahistory"
Column | Type | Modifiers
-----------------------------------+------------------------+-----------
id | bigint | not null
discriminator | character(1) | not null
[sniped non-relevant business columns]
fk_locationhistorytableid | bigint |
locationelementkey_person | integer |
locationelementkey_personlocation | integer |
locationelementkey_trip | integer |
Indexes:
"locationdatahistory_pkey" primary key, btree (id)
"locationdatahistory_discriminator_idx" btree (discriminator)
"locationdatahistory_sampleid_idx" btree (sampleid)
"locationdatahistory_transactionid_idx" btree (transactionid)
Foreign-key constraints:
"fk395eced5339a45c8" FOREIGN KEY (fk_locationhistorytableid) REFERENCES loca
tionhistorytable(id)