Sunday 24 May 2020

Exception in thread "main" org.hibernate.NonUniqueObjectException: A different object with the same identifier value was already associated with the session : [com.dreainno.hibernate.demo.entity.Student#0]

Solution:-

In the hibernate entity class we have to define genertion type strategy of id column. For example we have id column as autoincremented in sql table that will define in hibernate entity class as below:-

@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id")
private int id;

 I hope your error will be solve.
Happy Coding

No comments:

Post a Comment

Error While embed the video in Your website page

Error:- Refused to display '<URL>' in a frame because it set 'X-Frame-Options' to 'sameorigin Solution:- if ...