inserting data into database table via hibernate mapping fails <p>I am using Hibernate to insert a row into a database, I am using Visual Paradigm (Enterprise Edition) to generate database tables. </p> <p>Here are the errors</p> <blockquote> <p>org.orm.PersistentException: org.hibernate.PropertyValueException: not-null property references a null or transient value: com.patientmanagement.model.Patient.visitRecord at org.orm.PersistentSession.saveOrUpdate(PersistentSession.java:631) at org.orm.PersistentManager.saveObject(PersistentManager.java:287) at com.patientmanagement.model.PatientDAO.save(PatientDAO.java:303) at com.test.InsertData.main(InsertData.java:28) Caused by: org.hibernate.PropertyValueException: not-null property references a null or transient value: com.patientmanagement.model.Patient.visitRecord at org.hibernate.engine.Nullability.checkNullability(Nullability.java:100) at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:312) at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:203) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:129) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:117) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93) at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:687) at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:679) at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:675) at org.orm.PersistentSession.saveOrUpdate(PersistentSession.java:629) ... 3 more</p> </blockquote> <p>And here is the Insert function to test</p> <pre><code>public class InsertData { public static void main(String[]args) throws PersistentException { PersistentTransaction trans=PatientmanagementPersistentManager.instance().getSession().beginTransaction(); try { //create patient instance Patient patient=PatientDAO.createPatient(); //set patients properties patient.setName("Markus Rosevelt"); patient.setRegisterDate(new Date()); //save patient PatientDAO.save(patient); trans.commit(); }catch(Exception e){ trans.rollback(); } } } </code></pre>