How do I populate a drop down with a list using thymeleaf and spring

[solved] caused by: org.hibernate.PersistentObjectException: detached entity passed to persist:

The error looks like

org.hibernate.PersistentObjectException: detached entity passed to persist: example.forms.InvoiceItem     
    at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:127) 
    at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:799)     
    at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:791)     
    .... (truncated)

Solution

This exists in @ManyToOne and @ManytoMany relation. I solved this issue by just using CascadeType.MERGE instead of CascadeType.PERSIST or CascadeType.ALL.

Hope it helps you.

Leave a Comment

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply

    Your email address will not be published. Required fields are marked *