Wednesday, July 22, 2009

HibernateSystemException: attempted to assign id from null one-to-one property

I had a bidirectional relationship in my one-to-one mapping, however I had forgotten to set the objects in my Java code to reference each other. Once I had done that, the problem was resolved.

SpermAnalysis sa = new SpermAnalysis();
cryoSession.getControlMouse().setSpermAnalysis(sa);
// Bidirectional relationship
sa.setMouse(cryoSession.getControlMouse());

No comments:

Post a Comment