Okay, just incase this isn't clear enough for others and to make sure
I understand, I created a new table called HiValue and a PK field
named NextValue and seeded it with a default value of 0.  In my hbm
file for OrderHeader I now have:

      <generator class="hilo"    >
        <param name="table">HiValue</param>
        <param name="column">NextValue</param>
        <!--<param name="max_lo">100</param>-->
      </generator>

The max_lo property, is that just to indicate a max value?


Also, all the tables use an ID field, at least in the examples I'm
following, so am I supposed to use a seperate HiValue table for each
table I have?  Is that the proper way to ensure proper sequencing of
ID numbers?  So, for instance, I have two tables: OrderHeader and
OrderItem; is it best practice to create, say, OrderHeader_HiValue and
OrderItem_HiValue tables and seed them how I see fit (e.g. 0, 100,
etc) for a starting ID value?



btw, thanks for the link...

On Aug 20, 1:15 pm, "Frans Bouma" <[email protected]> wrote:
> http://www.nhforge.org/doc/nh/en/#mapping-declaration-id-generator
>
> see the snippet below 'hilo'. you have to create a table for the number and
> add a row.
>
>         FB
>
>
>
>
>
> > -----Original Message-----
> > From: [email protected] [mailto:[email protected]] On Behalf
> > Of nh_3478
> > Sent: vrijdag 20 augustus 2010 22:04
> > To: nhusers
> > Subject: [nhusers] "Invalid object name 'dbo.hibernate_unique_key'."
>
> > 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.- Hide quoted text -
>
> - Show quoted text -

-- 
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