Modelle verweisen auf sich und sind joinbar
This commit is contained in:
1 parent
4b6348a8f5
commit
b71cf3ee42
2 files changed
+13
No files matched your search
@@ -16,5 +16,8 @@ public class ShoppingListCategory extends ShoppingElement{
|
||||
private String categoryName;
|
||||
@OneToMany
|
||||
private List<ShoppingListItem> itemsInCategory;
|
||||
@ManyToOne
|
||||
@JoinColumn(name="list_id", nullable = false)
|
||||
private ShoppingList shoppingList;
|
||||
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package de.timaldinger.einkaufsliste.Models;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -14,4 +16,12 @@ public class ShoppingListItem extends ShoppingElement {
|
||||
private String itemName;
|
||||
private String itemAmount;
|
||||
private boolean isDone;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "category_id", nullable = true)
|
||||
private ShoppingListCategory category;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "list_id", nullable = false)
|
||||
private ShoppingList list;
|
||||
}
|
||||
Reference in new issue
Block a user