I\'ve got those two classes
MyItem Object:
@Entity
public class MyItem implements Serializable {
@Id
private Integer id;
@ManyToOne(casc
If name is the Id why are you creating two objects with the same id?? you can use the c1 object in all the code.
If that's only an example and you create the c2 object in another part of the code, then you shouldn't create a new object but load it from database:
c2 = itemDao.find("comp", Component.class); //or something like this AFTER the c1 has been persisted