Hi guys,
Getting one of them TransientObjectExceptions when trying to do this :
CandidateContactInfo info = new CandidateContactInfo();
info.setFirstName("HarryMetSally");
info.setLastName("SallyMetHarry");
Candidate c = new Candidate();
c.setAlias("Harry");
c.setEducation("PhD");
c.setCandidateContactInfo(info);
try {
// 2. Fire up Hibernate
Configuration cfg = new Configuration()
.addClass(Candidate.class)
.addClass(CandidateContactInfo.class)
.addClass(CandidateNote.class)
.addClass(CandidateReference.class)
.addClass(Competitor.class)
.addClass(Executive.class)
.addClass(Endclient.class)
.addClass(EndclientNote.class)
.addClass(Vendor.class)
.addClass(VendorClient.class)
.addClass(VendorNote.class)
.addClass(VendorPartner.class)
.addClass(VendorContact.class)
.addClass(ContactInfo.class)
.addClass(ContactNote.class)
.addClass(ClientContact.class)
.addClass(Contact.class)
.addClass(ReferenceContact.class)
.addClass(Requirement.class)
.addClass(RequirementNote.class)
.addClass(Resume.class)
.addClass(Company.class)
.addClass(Client.class)
.addClass(ClientNote.class)
.addClass(ClientPartner.class)
.addClass(ExecutiveInfo.class)
.addClass(Submission.class)
.addClass(SubmissionNote.class)
.addClass(Interview.class)
.addClass(InterviewNote.class)
.addClass(InterviewInterviewer.class)
.addClass(Interviewer.class);
SessionFactory sf = cfg.buildSessionFactory();
//System.out.println(p);
// 3. Open Session
Session sess = sf.openSession();
// 4. Save Product and close Session
Transaction t = sess.beginTransaction();
System.out.println("Saving data...");
sess.save(c);
t.commit();
sess.close();
I get this exception :
net.sf.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: vo.CandidateContactInfo
Any idea why ? I am adding CandidateContactInfo to my configuration, out which I'm getting my session, so that object should be in my session right ?
|