-->
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: Another way for creating mapping & classes for this schema?
PostPosted: Thu Dec 10, 2009 6:49 pm 
Newbie

Joined: Thu Dec 10, 2009 5:48 pm
Posts: 1
Hello,

I have the following DB schema:

Items(item_id, item_price, item_description, category, creation_date, last_update_date)
Item_Components(parent_id, component_id, effective_date, creation_date, last_update_date)

Where:
  • item_id is the primary key of the Items table
  • the columns parent_id, component_id, effective_date are the composite primary key for the ItemComponents table
  • the columnsparent_id and component_id are foreign keys referencing the item_id primary key of the Items table.

Right now I have the following entry in the Items mapping:

Code:
<list
        name="itemComponents"
        inverse="true"
        lazy="false"
    >
        <key>
            <column name="COMPONENT_ID" />
        </key>
        <one-to-many class="ItemComponent" />
</list>


And the class is:

Code:
public class Item  implements Serializable {
   private static final long serialVersionUID = 1L;
   private Long itemId;
   private java.sql.Date creationDate;
   private String itemCategory;
   private String itemDescription;
   private Long itemPrice;
   private java.sql.Date lastUpdateDate;
   private java.util.List<ItemComponent> itemComponents;
        .
        .
        .
}


There I have a collection of ItemComponent and the item component has the properties parent and component of type Items.


I would like to be able to have a class similar to this one:

Code:
public class Item  implements Serializable {
   private static final long serialVersionUID = 1L;
   private Long itemId;
   private java.sql.Date creationDate;
   private String itemCategory;
   private String itemDescription;
   private Long itemPrice;
   private java.sql.Date lastUpdateDate;
   private java.util.List<Item> itemComponents;
        .
        .
        .
}


Instead of having a collection of ItemComponent I would like to be able to have a collection of Item but I can't figure out a way of creating the Hibernate mapping.

Is there any way I can achieve this?


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.