org.hibernate.PersistentObjectException: detached entity passed to persist encountered by jpa
This happens because we have specified the generation strategy of the primary key in the entity class with JPA annotations. The primary key cannot be set. Once it is not empty or 0, it is considered to have been saved in the database. Once the persist() method is called, it will be thrown. The above exception
 Remove 0, as shown below:
Similar Posts:
- [Solved] Object references an unsaved transient instance – save the transient instance before flushing
- [Solved] Spring data JPA many to many relationship report detached entity passed to persist error
- [Solved] org.hibernate.AnnotationException: No identifier specified for entity: com.example1.demo1.Entity….
- Program error: the table or view does not exist [Solved]
- Springmvc Error: HTTP Status 500 – Could not write content: No serializer
- [Solved] Hibernate Error: org.hibernate.InstantiationException: No default constructor for entity
- Use of @OneToMany or @ManyToMany targeting an unmapped class: com.xxx.domain Error
- Hibernate:No default constructor for entity [How to Solve]
- MappedBy reference an unknown target entity property [How to Solve]