I'm to save a master/detail records in HR schema of the oracle database, but i have this error:
"SQL insert, update or delete failed (expected affected row count: 1, actual affected row count: 0). Possible causes: the row was modified or deleted by another user, or a trigger is reporting misleading row count."
my full code here:
Code:
Configuration cfg = new Configuration();
cfg.AddClass(typeof(NHDomainModel.Region));
cfg.AddClass(typeof(NHDomainModel.Country));
ISessionFactory factory = cfg.BuildSessionFactory();
ISession session = factory.OpenSession();
ITransaction tran = session.BeginTransaction();
NHDomainModel.Region myRegion = new NHDomainModel.Region();
myRegion.RegionName = "Latin America";
NHDomainModel.Country myCountry = new NHDomainModel.Country();
myCountry.CountryName = "Panama City";
myCountry.CountryId = "PM";
myCountry.Region = myRegion;
myRegion.Countries.Add(myCountry);
session.Save(myRegion);
session.Flush();
tran.Commit();
session.Close();
xml mapping:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="NHDomainModel.Region, NHDomainModel" table="REGIONS">
<id name="RegionId" column="REGION_ID" type="Int32" unsaved-value="0" >
<generator class="sequence">
<param name="sequence">REGION_SEQ</param>
</generator>
</id>
<property name="RegionName" column="REGION_NAME" type="String"/>
<set name="Countries" cascade="all" lazy="false" inverse="true">
<key column="REGION_ID" />
<one-to-many class="NHDomainModel.Country, NHDomainModel" />
</set>
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="NHDomainModel.Country, NHDomainModel" table="COUNTRIES">
<id name="CountryId" column="COUNTRY_ID" unsaved-value="" >
<generator class="assigned" />
</id>
<property name="CountryName" column="COUNTRY_NAME" />
<many-to-one name="Region" column="REGION_ID" class="NHDomainModel.Region, NHDomainModel" cascade="none" not-null="true" />
</class>
</hibernate-mapping>
thanks!