|
I'm new to Nhibernate and am using it in C# to access an Oracle database. I can make queries to the database correctly and I get back valid results. However, when I try to save a new object into the database, I always get an error.
This is my mapping file:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="WebsterBank.QualityAssurance.WtfInterface.Data"
assembly="WtfInterface" default-lazy="false">
<class name="Host" table="WIL_HOSTS">
<id name="ID" column="WIL_HOST_ID" type="Int32">
<generator class="assigned"/>
</id>
<property name="Name" column="NAME" type="String"/>
<property name="Address" column="ADDRESS" type="String"/>
<property name="DataSetID" column="DATA_SET_ID" type="Int32"/>
<property name="BypassSecurity" column="BYPASS_SECURITY" type="String"/>
<property name="Type" column="TYPE" type="String"/>
</class>
</hibernate-mapping>
My code that tries to save the object is the following:
public void addHost(Host hostToAdd) {
ISessionFactory factory = getSessionFactory();
ISession session = factory.OpenSession();
ITransaction tx = session.BeginTransaction();
session.Save(hostToAdd);
tx.Commit();
session.Flush();
session.Close();
factory.Close();
}
I get an error whenever the code tries to execute the tx.commit() statement. The error is the following:
NHibernate.ADOException: could not insert: [WebsterBank.QualityAssurance.WtfInterface.Data.Host#47][SQL: INSERT INTO WIL_HOSTS (NAME, ADDRESS, DATA_SET_ID, BYPASS_SECURITY, TYPE, WIL_HOST_ID) VALUES (?, ?, ?, ?, ?, ?)] ---> System.Data.OracleClient.OracleException: ORA-01400: cannot insert NULL into ("WIL_WTF"."WIL_HOSTS"."MODIFIABLE")
Does anyone know what might be causing this and/or a solution to this?
|