Hi there. But I dont have any such column namely
partsBackref for the parts table. I have only partName and partId. This program is basically a demonstration of collection mappng where one product can have many parts.
The following are my bean classes
Product.java
Code:
package hibernate;
import java.util.Set;
public class Product {
private int productId;
private Set parts; //One product can contain many parts
public Set getParts() {
return parts;
}
public void setParts(Set parts) {
this.parts = parts;
}
public int getProductId() {
return productId;
}
public void setProductId(int productId) {
this.productId = productId;
}
}
and
Parts.javaCode:
package hibernate;
import java.util.Set;
public class Parts {
private int partId;
private String partName;
private int productId;
public int getPartId() {
return partId;
}
public void setPartId(int partId) {
this.partId = partId;
}
public String getPartName() {
return partName;
}
public void setPartName(String partName) {
this.partName = partName;
}
public int getProductId() {
return productId;
}
public void setProductId(int productId) {
this.productId = productId;
}
}
These are the Tables that are created once I run the Program but no data is populated
SQL> desc parts;
Name Null? Type
----------------------------------------- -------- --------------------------
PARTID NOT NULL NUMBER(10)
PARTNAME VARCHAR2(255 CHAR)
PRODUCTID NOT NULL NUMBER(10)
SQL> desc products
Name Null? Type
----------------------------------------- -------- --------------------------
PRODUCTID NOT NULL NUMBER(10)
SQL>