-->
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: How to solve this ???
PostPosted: Mon Feb 08, 2010 6:40 am 
Newbie

Joined: Wed Jun 17, 2009 2:04 am
Posts: 6
Hai all
i had a class Instruction ..It looks like

Code:
public class InstructionLine implements Serializable {

       private Integer id;
       private Integer item;
   private Collection<InstructionLine> parents;// this is to be saved in instruction_hierarchy
   private Collection<InstructionLine> children;// this is to be saved in instruction_hierarchy

        ----getter and setter----------
}


I had tables like:

InstructionLine

id serial NOT NULL,
item_id integer NOT NULL



and instruction_hierarchy as

id serial NOT NULL,
parent_id integer NOT NULL,
child_id integer NOT NULL,



Can it be mapped correctly ...Am getting an error like

org.hibernate.MappingException: Association references unmapped class:


Top
 Profile  
 
 Post subject: Re: How to solve this ???
PostPosted: Mon Feb 08, 2010 7:06 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
From your post, It is not clear what you want:

1. According your code each InstructionLine can have:
-multiple parents
-multiple childrens

2. According your db schema each InstructionLine can have:
- one parent
- one child

3. Usually a parent-child relation is modeled OneToMany

Please give some more detailed informations on the mapping.


Top
 Profile  
 
 Post subject: Re: How to solve this ???
PostPosted: Mon Feb 08, 2010 7:28 am 
Newbie

Joined: Wed Jun 17, 2009 2:04 am
Posts: 6
Quote:
1. InstructionLine can have:
-multiple parents
-multiple childrens


Right..because I parent may be a child of another parent..

Quote:
2. According your db schema each InstructionLine can have:
- one parent
- one child


With this db design it is possible to store multiple parents and children...right..??

My mapping looks like:

Code:

<hibernate-mapping package="com.brainscript.tangram.sales.despatchorder.domain.impl">
   <class name="BaseDespatchOrderLines" table="inventory.despatch_order_lines">
      
      <id   name="id" column="id" unsaved-value="null">
         <generator class="sequence">
            <param name="sequence">inventory.instruction_lines_id_seq</param>
         </generator>
      </id>

      <property name="comments" column="comments"/>
      <property name="item" column="item_id"/>   
      
      
   //Is this possible
   <!--   <bag name="children" cascade="all-delete-orphan" lazy="false" table="inventory.instruction_hierarchy">
         <key column="id" not-null="true"/>
         <one-to-many class="com.brainscript.tangram.sales.salesorder.domain.impl.InstructionLine"/>
      </bag>-->


   </class>
   
   
   
   
   
</hibernate-mapping>


Top
 Profile  
 
 Post subject: Re: How to solve this ???
PostPosted: Mon Feb 08, 2010 8:42 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
According java code, children is a property declared in class InstructionLine
According your hbm-file, children is a property declared in class BaseDespatchOrderLines

This does not fit.


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.