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?