1. Exception: org.hibernate.transientobjectexception: object references an unsaved transient instance – save the transient instance before flushing:
This is mainly encountered during the manytoone cascade operation. For example, a new object is saved into a new new object before it is saved (that is, it is not persistent)
The solution is to find out the object before saving or updating (this is a persistent state)
The solution is to set the cascade of many-to-one as: cascade = “save update, persist”
Four cascade types:
* persistent: when the owner entity is persisted, all related data of the entity will also be persisted
* merge: when a detached entity is re merged into the persistence context of an activity, all relevant data of that entity will also be merged
* remove: when an entity is deleted, all related data of the entity will also be deleted
* all: all of the above are applicable
2. Exception 1: not nullproperty references anullortransientvalue
solution: set not null to false for the “one” party in the “one to many” relationship
Exception 2: org. Hibernate. Transientobjectexception: object references an unsaved transient instance
solution: cascade = “save update, persist”
Exception 3: org. Hibernate. Queryexception: could not resolve property
solution: “from category category where category. Userid =: userid” is modified to “from category where userid =: userid” or “from category category where category. User. Id =: userid”
Exception 4: could not initialize proxy – the owning session was closed
solution: set lazy to false
Similar Posts:
- [Solved] Spring data JPA many to many relationship report detached entity passed to persist error
- org.hibernate.PersistentObjectException: detached entity passed to persist encountered by jpa
- [Solved] Hibernate Error: org.hibernate.InstantiationException: No default constructor for entity
- Hibernate:No default constructor for entity [How to Solve]
- Springmvc Error: HTTP Status 500 – Could not write content: No serializer
- Postman passing Josn field error: Cannot deserialize instance of `java.util.ArrayList` out of VALUE_STRING token
- [Solved] MYSQL add foreign key error: Referencing column ‘xx’ and referenced column ‘xx’ in foreign key constraint ‘xxx’ are incompatible.
- [Solved] java.lang.ClassCastException: Ljava.lang.Object; cannot be cast to com.entity.Advertisem
- How to Solve the inaccessibility of Website After the SSL certificate is added
- [Solved] org.hibernate.AnnotationException: No identifier specified for entity: com.example1.demo1.Entity….