Hello I have serious problem and I can't find solution.
My problem is in mapping this example:
----------------------------------------------------
//Class Order reperesent basic order, can containts more OrderItem
class Order {
private int id_o;
private Set<OrderItem> orderItems;
...
}
//class reprezent oreder item and can contain only one product and its //quantity
class OrderItem {
private int quantity;
private Product product;
}
//class represent basic product
class Product {
private int id_p;
private String name;
.....
}
I would like to map it into join table , but i don't know how should map atrribute quantity.
I know that I should use many-to-many mapping, but i know only use it when I don't have attribute quantity.
ERD:(Tables)
ORDER
------------
ID_O integer auto_increment PK
PRODUCT
-----------
ID_P integer auto_increment PK
NAME varchar(20)
ORDER_ITEM
-----------------
ID_O PK,FK
ID_P PK,FK
QUANTITY integer
But how should it map in hibernate, I really don't know.
If someone know, please help me.
Thanks for your help
geN.
|