Hi guys,
I have got a onetomany relation in Hibernate:
@Entity
public class Project
@OneToMany(cascade = CascadeType.ALL)
@OrderColumn(name = "project_index")
List<Application> applications;
@Entity
public class Application
Now, I tried to update an application directly:
session.merge(application);
The result is that a new Application is created, instead of updating the entity. How can I reatach my entity properly and update my entity?
Thank you
Solution:
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Application)) {
return false;
}
Application app = (Application)obj;
return id == app.getId();
}
@Override
public int hashCode () {
return status.hashCode();
}