JPA: IllegalStateException: During synchronization a new object was found through a relationship that was not marked cascade PERSIST

Maxim6394

Bekanntes Mitglied
Hallo, ich bekomme hier gerade folgenden Fehler wenn ich eine neue Entität anlegen will: JPA: IllegalStateException: During synchronization a new object was found through a relationship that was not marked cascade PERSIST

Es handelt sich um diese Entität:

Java:
@Entity
public class  StockItemProductAssociation {

    public StockItemProductAssociation() {}

    public StockItemProductAssociation(StockItem stockItem, Product shopProduct) {
        this.stockItem = stockItem;
        this.product = shopProduct;
    }

    @Id
    @ManyToOne(fetch=FetchType.EAGER)
    @JoinColumn(name = "STOCKITEM_NUMBER")
    public StockItem stockItem;

    @Id
    @ManyToOne(fetch=FetchType.EAGER)
    @JoinColumn(name = "PRODUCT_NUMBER")
    public Product product;


  ...  

}

stockItem und product enthalten ein neues Objekt was auch angelegt werden sollte. Da ist jeweils dieser Verweis enthalten (mit dem entsprechenden Wert für mappedBy):

Code:
 @OneToMany(mappedBy = "stockItem", cascade = CascadeType.ALL, orphanRemoval = true)
    public List<StockItemProductAssociation> itemProductAssociations = new ArrayList();

Woran liegt das? Ich hab da überall CascadeType.ALL geschrieben.
 
Ähnliche Java Themen
  Titel Forum Antworten Datum
V Communication failure during handshake Datenbankprogrammierung 6

Ähnliche Java Themen

Neue Themen


Oben