-->
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: Using persistent object as component inside other object
PostPosted: Thu Jan 20, 2005 5:39 am 
Newbie

Joined: Thu Aug 05, 2004 10:51 am
Posts: 2
This is my situation:

Code:

/**
* @hibernate.class
*/
public class Person {
}

/**
* @hibernate.class
*/
public class Organisation {

  /**
   * @hibernate.set cascade="all" lazy="true" inverse="true"
   * @hibernate.collection-key column="organisationId"
   * @hibernate.collection-one-to-many class="Person"
   */
  public Set getEmployees() {
  }
}

/**
* @hibernate.class
*/
public class ConceptOrganisation {
 
    /**
     * @hibernate.component class="Organisation"
     */
  public Organisation getOrganisation() {
  }
}


Hibernate mapping file of conceptorganisation:

<hibernate-mapping>
    <class name="ConceptOrganization">
        <id name="id" column="id" type="java.lang.Long">
            <generator class="native" />
        </id>

        <component name="organisation" class="Organisation">

            <set name="employees">
                <key column="organizationId" />
                <one-to-many class="Person" />
            </set>
        </component>
   </class>
</hibernate-mapping>



Now i have a Organisation with ID = 1 and a ConceptOrganisation with ID = 1.
Organisation 1 has relation to 3 person objects in the database.

The problem pops up when i get the conceptorganisation with id = 1 from the database. Suddenly also the 3 person objects appear in my conceptorganisation.
The organisation component inside the conceptorganisation may have a list of person-objects, but there should be no relation between the person-object and the conceptorganisation.

How can i overcome this problem. I don't want to copy all properties from the organisation object into the conceptorganisation object.


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.