Please help me with my issue.
This sample i took from Openjpa samples.
two classes
InventoryCategory.java
@OneToMany(targetEntity=gov.ssa.rome.model.InventoryItem.class,
cascade=CascadeType.ALL,
mappedBy="category")
public List<InventoryItem> getItems()
{
return items;
}
InventoryItem.java
@ManyToOne
@JoinColumn(name="CAT_ID", nullable=false)
public InventoryCategory getCategory()
{
return category;
}
I am trying to use like this below in my Test.java
InventoryCategory cat = new InventoryCategory();
cat.setCategoryName("testname");
cat.setCategoryDescription("testdescription");
List<InventoryItem> items= new ArrayList<InventoryItem>();
InventoryItem item = new InventoryItem();
item.setItemName("name");
item.setItemDescription("description");
item.setItemPrice(1);
items.add(item);
cat.setItems(items);
em.persist(cat);//expecting to save all the items and category in there
respective tables with this call.
but it is not happening.
May i know how this onetomany work if i want my expected result to happen?
Thanks in advance.
-Venra
--
View this message in context:
http://openjpa.208410.n2.nabble.com/I-am-not-able-to-store-the-children-to-the-parent-at-a-time-using-onetomany-tp5771993p5771993.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.