Use merge()
. The exception means that the current session is already aware of the entity you are passing. If not, check how you have overridden hashCode()
and equals()
– it should return different values for different entities.
More Related Contents:
- Hibernate: CRUD Generic DAO
- java.lang.ClassCastException: java.lang.String cannot be cast to
- Where does the @Transactional annotation belong?
- How to solve the “failed to lazily initialize a collection of role” Hibernate exception
- How can I log SQL statements in Spring Boot?
- What is the proper way to re-attach detached objects in Hibernate?
- No Dialect mapping for JDBC type: 1111
- Annotation @Transactional. How to rollback?
- @Transactional method called from another method doesn’t obtain a transaction
- How to set up default schema name in JPA configuration?
- Transaction marked as rollback only: How do I find the cause
- Transactional saves without calling update method
- Spring data JPA and hibernate detached entity passed to persist on ManyToMany relationship
- Hibernate could not fetch the SequenceInformation from the database
- Do you need a database transaction for reading data?
- Java / Hibernate – Write operations are not allowed in read-only mode
- Difference between save and saveAndFlush in Spring data jpa
- The onFlushDirty Hibernate Interceptor method is never called
- spring data jpa @query and pageable
- compatibility of spring 4.0.0 with hibernate 4.30 [duplicate]
- Hibernate, spring, JPS & isolation – custom isolation not supported
- Why HibernateTemplate isn’t recommended? [duplicate]
- Hibernate, Java 9 and SystemException
- Enumerations in Hibernate
- Spring 3.1, Hibernate 4, SessionFactory
- java.lang.IllegalStateException: No transactional EntityManager available
- hibernate two tables per one entity
- Array with UserType in Hibernate and PostgreSQL –> MappingException
- FetchMode join makes no difference for ManyToMany relations in spring JPA repositories
- How to find distinct rows with field in list using JPA and Spring?