I can't work out why values from the beans aren't being bound properly. This is my code:
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
InterviewQuestion iq = (InterviewQuestion)f.get("generic_1"); //from UI
session.lock(iq, LockMode.READ);
Iterator iter = iq.getAnswerOptions().iterator();
while(iter.hasNext()) {
AnswerOption ao = (AnswerOption)iter.next();
if(ao.isSelected()) {
iq.addInterviewAnswer(new InterviewAnswer(iq, ao)); // not binding
}
}
session.saveOrUpdate(iq); // cascade="save-update" in config
tx.commit();
HibernateUtil.closeSession();
This is the (cut down) log that shows nulls being bound:
Hibernate: insert into Interview_Answers (INTERVIEW_QUESTION_ID, ANSWER_ID, ID) values (?, ?, ?)
net.sf.hibernate.type.LongType - binding null to parameter: 1
net.sf.hibernate.type.LongType - binding null to parameter: 2
net.sf.hibernate.type.LongType - binding '2' to parameter: 3
Thanks!
|