I was going throught the samples of
Category
Item
CategorizedItem
If is save the category ,its fine
In another case if i save the category and the Item it is fine
In another case I load the saved category and the Item and save the
Catgorized item, it is fine
In another case when i try to save a new instance of category, instance of item and instance of categorizedItem in single save
i.e
Catgeory catgeory = new Catgeory();
//fill attributes
Item item = new Item();
// fill attributes
String user= "james";
CategorizedItem item = new CategorizedItem(user,catgeory,item);
// over here you do the linking stuff in the example
session.save(catgeory);
I get errors in the link table saving it mentions that the
Caused by: java.sql.BatchUpdateException: ORA-01400: cannot insert NULL into ("SCOTT"."CATEGORIZED_ITEM"."CATEGORY_ID")
In the CategorizedItem Class
====================
public CategorizedItem(String username, Category category, Item item) {
this.username = username;
this.category = category;
this.item = item;
// Set key values
this.id.categoryId = category.getId();
this.id.itemId = item.getId();
// Guarantee referential integrity
category.getCategorizedItems().add(this);
item.getCategorizedItems().add(this);
}
this.id.categoryId = category.getId();
this.id.itemId = item.getId();
over hear since the category is not saved and the item is not saved, the ids are null and as a result its not generating the sql properly. to insert in the link table
Is there something else i need to do ? to make sure its capable of doing this
|