You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Category @table(name = "Categories")
public class Category extends Model {
@Column(name = "Name", notNull = true, unique = true)
public String name;
public List<Item> items() {
return getMany(Item.class, "Category");
}
public Category() {
super();
}
public Category(String name) {
super();
this.name = name;
}
@Override
public String toString() {
return new String("[" + Category.class.getName() + "] "
+ "Name = " + name);
}
}
Item
@table(name = "Items")
public class Item extends Model {
@Column(name = "Name", notNull = true, unique = true)
public String name;
@Column(name = "Category", onDelete = ForeignKeyAction.CASCADE)
public Category category;
public Item() {
super();
}
public Item(String name, Category category) {
super();
this.name = name;
this.category = category;
}
@Override
public String toString() {
return new String("[" + Item.class.getName() + "] "
+ "Name = " + name + " | "
+ "Category = " + category);
}
}
After saving one Category data with many items, when I delete the inserted Category, the items remain in database. Is the CASCADE Action upon onDelete is working ? How to establish properly ForeignKeyActions ?
Thanks.
The text was updated successfully, but these errors were encountered:
Hi,
Lets take your example with Category and Item.
Category
@table(name = "Categories")
public class Category extends Model {
}
Item
@table(name = "Items")
public class Item extends Model {
}
After saving one Category data with many items, when I delete the inserted Category, the items remain in database. Is the CASCADE Action upon onDelete is working ? How to establish properly ForeignKeyActions ?
Thanks.
The text was updated successfully, but these errors were encountered: