-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Trigger-Identity with Dynamic Insert throws ORA-01036 (10g)
PostPosted: Mon Jun 29, 2009 1:42 pm 
Newbie

Joined: Mon Jun 29, 2009 1:17 pm
Posts: 2
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!


Top
 Profile  
 
 Post subject: Re: Trigger-Identity with Dynamic Insert throws ORA-01036 (10g)
PostPosted: Fri Jul 17, 2009 5:43 pm 
Newbie

Joined: Mon Jun 29, 2009 1:17 pm
Posts: 2
I have reported this as a bug. See NH-1893


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.