I get a genericadoexception with error {"could not get or update next
value[SQL: ]"}
and InnerException: "Invalid object name 'dbo.hibernate_unique_key'."

I am following, to the T, the Nhibernate 2 book by Aaron Cure.


//mssql 2008 express edition with table
OrderHeader
PK = Id, type = int
then the rest of values seen in the constructor below are also there.

//my OrderHeader.hbm.xml file
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="Ordering.Data" namespace="Ordering.Data"  >
  <class name="Ordering.Data.OrderHeader, Ordering.Data"
table="OrderHeader" schema="dbo"  >
    <id name="Id" type="int"  >
      <column  name="Id"   />
      <!--<column  name="Id" length="4" sql-type="int" not-null="true"
unique="true" index="PK_OrderHeader" />-->
      <generator class="hilo"    >
        <!--<param name="max_lo">100</param>-->
      </generator>
    </id>
    <property name="Number" type="String"/>
    <property name="OrderDate" type="DateTime"/>
    <property name="ItemQty" type="Int32"/>
    <property name="Total" type="Decimal"/>
  </class>
</hibernate-mapping>


//OrderHeader class snipet...
namespace Ordering.Data
{
    public class OrderHeader
    {
        private int _id;

        public virtual int Id
        {
            get { return _id; }
            set { _id = value; }
        }
...

When I try to save using code like so, I get the aformentioned errors.

//code
            OrderHeader oh = new OrderHeader("10", DateTime.Now, 2,
105, c, null, null, null);
            //oh.Id = 51;
            session.Save(oh);


Now, I have it boiled down to the hilo generator.  If I remove the
generator from the hbm.xml file, and assign a value to oh.Id = 51,
then my object saves and the row is inserted into the database.  How
do I get this generator to work, though???  I've also tried native,
but then I get a different error that it can't INSERT into database
using NULL ID...somehow the generator is NOT assigning a valid value
to my ID in my OrderHeader class.

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to