-->
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: many to many mapping of a Map
PostPosted: Sun Nov 07, 2004 7:12 am 
Newbie

Joined: Sun Nov 07, 2004 6:58 am
Posts: 8
Location: HH Germany
Hi,

i have a mapping like this:


i just will mapping a Map in

Hibernate version: 2.1.6

Code:
        <class name="Page" table="pages">
                <id name="id" column="id" unsaved-value="-1">
                        <generator class="identity"/>               
                </id>
                <property name="name" column="name"/>
                <set name="htmlsInternal" table="page_htmls">
                        <key column="page_id"/>
                        <many-to-many column="html_id" class="Html"/>
                </set>
        </class>

        <class name="Html" table="htmls">
                <id name="id" column="id" unsaved-value="-1">
                        <generator class="identity"/>
                </id>
                <property name="name" column="name"/>
                <property name="code" column="code"/>
                <property name="datetime" column="datetime"/>
                <property name="active" column="active"/>
                <property name="lang" column="lang"/>
        </class>


this is working but now i must change the collection type for the html objects in page object to a map.

so i changed my mapping to this:

Code:
        <class name="Page" table="pages">
                <id name="id" column="id" unsaved-value="-1">
                        <generator class="identity"/>               
                </id>
                <property name="name" column="name"/>
                <map name="htmlsInternal" table="page_htmls">
                        <key column="page_id"/>
                        <index-many-to-many column="html_id" class="Html"/>
                </map>
        </class>

        <class name="Html" table="htmls">
                <id name="id" column="id" unsaved-value="-1">
                        <generator class="identity"/>
                </id>
                <property name="name" column="name"/>
                <property name="code" column="code"/>
                <property name="datetime" column="datetime"/>
                <property name="active" column="active"/>
                <property name="lang" column="lang"/>
        </class>


but hits dos not work, i allways get a mapping error

can anyone tell me how must change the mapping that it is correct?

Thank you.

mfg Gideon


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 07, 2004 4:10 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Please refer to the documentation. You're missing the <many-to-many> part

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 07, 2004 6:18 pm 
Newbie

Joined: Sun Nov 07, 2004 6:58 am
Posts: 8
Location: HH Germany
Hi,

I found the mistakes.

the mapping i now use is:
Code:
   <class name="Page" table="pages">
      <id name="id" column="id" unsaved-value="-1">
         <generator class="identity"/>              
      </id>
      <property name="name" column="name"/>
      <map name="htmlsInternal" table="page_htmls">
         <key column="page_id"/>         
         <index column="htmls" type="integer"/>
         <many-to-many column="html_id" class="Html"/>         
      </map>
   </class>


with this I have three columns at the page_htmls table and two of them have the same content
but when I change the index column to html_id I get a error because repeated column.

Is there a solution to to use the html_id column as Map index too ?

Thank you

mfg Gideon


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 08, 2004 7:39 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
No, Hibernate keep the same freedom as your Java Map have

_________________
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.