Note that there are some explanatory texts on larger screens.

plurals
  1. PONHibernate GenericADO Exception
    primarykey
    data
    text
    <p>I'm trying to make simple many-to-one association, using NHibernate.. I have class Recruit with this mapping:</p> <pre><code>&lt;class name="Recruit" table="Recruits"&gt; &lt;id name="ID"&gt; &lt;generator class="native"/&gt; &lt;/id&gt; &lt;property name="Lastname" column="lastname"/&gt; &lt;property name="Name" column="name"/&gt; &lt;property name="MedicalReport" column="medicalReport"/&gt; &lt;property name="DateOfBirth" column ="dateOfBirth" type="Date"/&gt; &lt;many-to-one name="AssignedOnRecruitmentOffice" column="assignedOnRecruitmentOffice" class="RecruitmentOffice"/&gt; </code></pre> <p></p> <p>which is many-to-one connected to RecruitmentOffices:</p> <pre><code>&lt;class name="RecruitmentOffice" table="RecruitmentOffices"&gt; &lt;id name="ID" column="ID"&gt; &lt;generator class="native"/&gt; &lt;/id&gt; &lt;property name="Chief" column="chief"/&gt; &lt;property name="Name" column="name"/&gt; &lt;property name ="Address" column="address"/&gt; &lt;set name="Recruits" cascade="save-update" inverse="true" lazy="true"&gt; &lt;key&gt; &lt;column name="AssignedOnRecruitmentOffice"/&gt; &lt;/key&gt; &lt;one-to-many class="Recruit"/&gt; &lt;/set&gt; </code></pre> <p></p> <p>And create Repository class with method Insert:</p> <pre><code> public void Insert(Recruit recruit) { using (ITransaction transaction = session.BeginTransaction()) { session.Save(recruit); transaction.Commit(); } } </code></pre> <p>then I try to save new recrui to base:</p> <pre><code> Recruit test = new Recruit(); RecruitmentOffice office = new RecruitmentOffice(); ofice.Name = "test"; office.Chief = "test"; test.AssignedOnRecruitmentOffice = office; test.Name = "test"; test.DateOfBirth = DateTime.Now; RecruitRepository testing = new RecruitRepository(); testing.Insert(test); </code></pre> <p>And have this error</p> <pre><code> GenericADOException could not insert: [OSiUBD.Models.DAO.Recruit][SQL: INSERT INTO Recruits (lastname, name, medicalReport, dateOfBirth, assignedOnRecruitmentOffice) VALUES (?, ?, ?, ?, ?); select SCOPE_IDENTITY()] </code></pre> <p>on session.Save</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload