-->
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.  [ 1 post ] 
Author Message
 Post subject: mapping question
PostPosted: Fri Nov 12, 2004 12:19 pm 
Newbie

Joined: Fri Nov 12, 2004 11:40 am
Posts: 1
Hi,

I'm pretty new at hibernate, so I have been testing it out on a project, everything was going pretty well, till I tried to map the following..

a little model of what I'm trying to map.
Image

Activity has a 1 to 1 relation with ImageCollection, in ImageCollection theres a List holding instances of Image.

The problem now is I want a person to have a picture, the pictures of all persons are saved in 1 "standard" ImageCollection.
So when I map the Person class I somehow have to give the collection_id of the ImageCollection where the picture of the person should be saved in.

I wrote comment in the Person class mapping.
Mapping documents:
Code:
<hibernate-mapping package="com.project.model">

   <class name="Activity">
      <id name="id" type="long" column="activity_id">   
         <generator class="native"/>
      </id>
      <property name="name" not-null="true"/>
      <many-to-one name="picturemap" class="ImageCollection" column="collection_id" cascade="all" unique="true"/>
   </class>
   
   <class name="ImageCollection">
      <id name="id" type="long" column="collection_id">   
         <generator class="native"/>
      </id>
      <property name="name" unique="true"/>
      
      <bag name="images" lazy="true" cascade="all">
            <key column="collection_id"/>
            <one-to-many class="Image"/>
        </bag>
   </class>
   
   <class name="Image">
      <id name="id" type="long" column="picture_id">   
         <generator class="native"/>
      </id>
      <property name="path"/>
   </class>
   
   <class name="Person">
      <id name="id" type="long" column="person_id">   
         <generator class="native"/>
      </id>
      <property name="name"/>
      
      <one-to-one name="picture" class="Image" cascade="all"/>
//if I map it like this the collection_id of the picture becomes NULL of course, but I have no idea how it should be done.
   </class>

</hibernate-mapping>


Is it possible to map something like this or do I have to start thinking about a whole different approach?

Thx in advance


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.