-->
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.  [ 2 posts ] 
Author Message
 Post subject: Howto get <composite-map-key> properties in the <ma
PostPosted: Thu Nov 03, 2005 3:51 pm 
Newbie

Joined: Tue Jan 04, 2005 4:52 pm
Posts: 13
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)



Top
 Profile  
 
 Post subject: Using a <many-to-many> value in the mapping
PostPosted: Thu Nov 03, 2005 4:54 pm 
Newbie

Joined: Tue Jan 04, 2005 4:52 pm
Posts: 13
Hello,

I was able to get the <map> specified table to generate if I used a <many-to-many> relationship for the map value.

The queries generated by hibernate with the <many-to-many> value are correct and work properly.

In the <one-to-many> case the SQL generated was incorrect and caused exceptions.

Kastor


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