The solution is simple, just use the CascadeType.MERGE
instead of CascadeType.PERSIST
or CascadeType.ALL
.
I have had the same problem and CascadeType.MERGE
has worked for me.
I hope you are sorted.
More Related Contents:
- How to fix the Hibernate “object references an unsaved transient instance – save the transient instance before flushing” error
- What is the difference between persist() and merge() in JPA and Hibernate?
- JPA JoinColumn vs mappedBy
- Difference between FetchType LAZY and EAGER in Java Persistence API?
- How to map an entity field whose name is a reserved word in JPA
- Why is Hibernate Open Session in View considered a bad practice?
- What’s the difference between JPA and Hibernate? [closed]
- What is the solution for the N+1 issue in JPA and Hibernate?
- Wrong ordering in generated table in jpa
- Solve Hibernate Lazy-Init issue with hibernate.enable_lazy_load_no_trans
- Configure hibernate (using JPA) to store Y/N for type Boolean instead of 0/1
- what is @JoinColumn and how it is used in Hibernate
- JPA eager fetch does not join
- In which case do you use the JPA @JoinTable annotation?
- How can I get the session object if I have the entity-manager?
- No Dialect mapping for JDBC type: 1111
- Hibernate one-to-one: getId() without fetching entire object
- JPA: Implementing Model Hierarchy – @MappedSuperclass vs. @Inheritance
- Hibernate: Where do insertable = false, updatable = false belong in composite primary key constellations involving foreign keys?
- Hibernate generates negative id values when using a sequence
- How to prevent SQL Injection with JPA and Hibernate?
- Specifying an Index (Non-Unique Key) Using JPA
- Hibernate: Create Mysql InnoDB tables instead of MyISAM
- IN-clause in HQL or Java Persistence Query Language
- Disable caching in JPA (eclipselink)
- How to set the timeout period on a JPA EntityManager query
- Hibernate throws strange error: Class is not mapped
- When to use DiscriminatorValue annotation in hibernate
- Unsuccessful: alter table XXX drop constraint YYY in Hibernate/JPA/HSQLDB standalone
- JPA: difference between @JoinColumn and @PrimaryKeyJoinColumn?