I am trying to update some data in my table. Maybe i am doing it the wrong way.
So when i try to update anything else, it will permit me but when i try to update the Foreign key of an One To One relation it will drop me this
15:21:53,367 INFO [STDOUT] org.hibernate.HibernateException: identifier of an instance of project.entities.CloneNumber was altered from 2a to 2aa
i have my CloneNumber is One to One with Ligation .
public void updateLigation(int id, String plasmid, String ins1, String ins2, String oldClone, String cloNum, String cons){
try{
LigationExperiment lig = manager.find(LigationExperiment.class, id);
lig.setPlasmid(plasmid);
lig.setInsert1(ins1);
lig.setInsert2(ins2);
lig.setConstructedPlasmid(cons);
lig.setCloneNumber(updateCloneNum(oldClone,cloNum));
System.out.println("Will not come here.");
} catch (Exception e){
System.out.println(e.getMessage());
}
}
.
public CloneNumber updateCloneNum(String oldClone,String cloneNo){
CloneNumber n = manager.find(CloneNumber.class, oldClone);
n.setCloneNo(cloneNo);
System.out.println(n.getBatch() + n.getCloneNo());
manager.flush();
n = manager.find(CloneNumber.class, cloneNo);
return n;
}
Let me note than when i update anything else and not the cloneNumber it will permit me, but when i try to update that it will not allow me.
/************** Ligation **************/
// Setting the relationship for OneToOne for CloneNumber.java
private CloneNumber cloNum;
@OneToOne
public CloneNumber getCloneNumber() { return cloNum; }
public void setCloneNumber(CloneNumber cloNum) { this.cloNum = cloNum; }
How can i update the primary key of a foreign key and then allocate it to my table succesfully ?