If someone could please confirm this is a bug or user error, I would be most appreciative.
Using NHibernate-2.1.0.Beta2, Oracle10gDialect, dynamic-insert="true" and a trigger-identity, the SQL generated is missing the "returning ID into :nhIdOutParam" clause, causing an ORA-01036 error. Take out the dynamic-insert, and all is well.
Here's what I came up with for a test case (based on the NHibernate.LiteTestSolution):
Code:
namespace NHibernate.Test.NHSpecificTest.NHxxxx
{
public class DomainClass
{
private int id;
public virtual int Id
{
get { return id; }
set { id = value; }
}
private string data;
public virtual string Data
{
get { return data; }
set { data = value; }
}
}
}
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test"
namespace="NHibernate.Test.NHSpecificTest.NHxxxx" default-access="field.camelcase"
default-lazy="false">
<class name="DomainClass" dynamic-insert="true">
<id name="Id" column="Id">
<generator class="trigger-identity" />
</id>
<property name="Data" column="Data" type="string" />
</class>
</hibernate-mapping>
namespace NHibernate.Test.NHSpecificTest.NHxxxx
{
[TestFixture]
public class SampleTest : BugTestCase
{
protected override void OnSetUp()
{
base.OnSetUp();
}
protected override void OnTearDown()
{
base.OnTearDown();
/*using (ISession session = this.OpenSession())
{
string hql = "from System.Object";
session.Delete(hql);
session.Flush();
}*/
}
protected override bool AppliesTo(NHibernate.Dialect.Dialect dialect)
{
return dialect as Oracle10gDialect != null;
}
[Test]
public void TriggerIdentityInsertWithDynamicInsert()
{
using (ISession session = this.OpenSession())
{
DomainClass entity = new DomainClass();
entity.Data = "test";
session.Save(entity);
session.Flush();
}
}
}
}
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
...
<property name="connection.driver_class">NHibernate.Driver.OracleDataClientDriver</property>
<property name="dialect">NHibernate.Dialect.Oracle10gDialect</property>
The SQL generated is:
INSERT INTO DomainClass (Data) VALUES (:p0);:p0 = 'test', :nhIdOutParam = NULL
Thanks!