This happens if you have not create a hilo table, or have created the
hilo table but it is not seeded it with an initial value.

NHibernate is complaining (in a non-obvious way) that it couldn't
generate the next hi value.

On May 30, 5:45 am, Paul Batum <paul.ba...@gmail.com> wrote:
> Maybe someone that has used hilo will pipe up with a suggestion, but in the
> meantime I suggest you ask on the nhibernate
> users<http://groups.google.com/group/nhusers/> mailing
> list. Your question is more about NH usage than the FNH mappings.
>
>
>
> On Sat, May 29, 2010 at 2:23 AM, Sosh <bgs...@gmail.com> wrote:
> > Hi,
>
> > I've been building an app with Native Ids initially, and am now
> > switching to HiLos.
>
> > However, I've come across a strange problem, and don't understand
> > what's happening.
>
> > With native ids everything is working fine.  However, if I one of the
> > entity mappings to HiLo, new objects will not persist in the database
> > (using SaveOrUpdate).  I don't receive any errors and no exception is
> > thrown - everything acts like it's working, but no new db records.
>
> > I'm just using default hilo settings.  I'm recreating the DB with
> > SchemaUpdate/Export beforehand, and the Hibernate_Unique_Key table
> > with the next_hi column is being created correctly.
>
> > Here's the original mapping line that works:
>
> > Id(c => c.Id).GeneratedBy.Native();
>
> > And the one that breaks everything:
>
> > Id(c => c.Id).GeneratedBy.HiLo("100");
>
> > If I try to SaveOrUpdate() a new object, all I get in the sql logs is:
>
> > 2010-05-28 18:15:09,703 DEBUG 4 NHibernate.SQL - Reading high
> > value:select next_hi from hibernate_unique_key for update
> > 2010-05-28 18:15:09,718 DEBUG 4 NHibernate.SQL - Updating high
> > value:update hibernate_unique_key set next_hi = ?p0 where next_hi = ?
> > p1;?p0 = 4, ?p1 = 3
>
> > And in the nhibernate log:
>
> > 2010-05-28 18:18:33,734 DEBUG 8 NHibernate.Impl.SessionImpl - [session-
> > id=a948d92d-3edc-4f15-aa5a-3b7d461cb455] opened session at timestamp:
> > 634106675137, for session factory: [/046fd6ce97f547aeb8a9edb8ddf6e2ef]
> > 2010-05-28 18:18:33,734 DEBUG 8 NHibernate.Engine.IdentifierValue -
> > unsaved-value: 0
> > 2010-05-28 18:18:33,734 DEBUG 8
> > NHibernate.Event.Default.AbstractSaveEventListener - transient
> > instance of: xxxx.BusinessEvent
> > 2010-05-28 18:18:33,734 DEBUG 8
> > NHibernate.Event.Default.DefaultSaveOrUpdateEventListener - saving
> > transient instance
> > 2010-05-28 18:18:33,734 DEBUG 8
> > NHibernate.Event.Default.AbstractSaveEventListener - generated
> > identifier: 304, using strategy: NHibernate.Id.TableHiLoGenerator
> > 2010-05-28 18:18:33,734 DEBUG 8
> > NHibernate.Event.Default.AbstractSaveEventListener - saving
> > [xxxx.BusinessEvent#304]
> > 2010-05-28 18:18:33,734 DEBUG 8 NHibernate.Impl.SessionImpl - [session-
> > id=a948d92d-3edc-4f15-aa5a-3b7d461cb455] running ISession.Dispose()
> > 2010-05-28 18:18:33,734 DEBUG 8 NHibernate.Impl.SessionImpl - [session-
> > id=a948d92d-3edc-4f15-aa5a-3b7d461cb455] executing real Dispose(True)
> > 2010-05-28 18:18:33,734 DEBUG 8 NHibernate.Impl.SessionImpl - closing
> > session
> > 2010-05-28 18:18:33,734 DEBUG 8 NHibernate.AdoNet.AbstractBatcher -
> > running BatcherImpl.Dispose(true)
>
> > Any ideas what the problem might be? Or what to check?
>
> > Thanks
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Fluent NHibernate" group.
> > To post to this group, send email to fluent-nhibern...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > fluent-nhibernate+unsubscr...@googlegroups.com<fluent-nhibernate%2Bunsubscr 
> > i...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/fluent-nhibernate?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibern...@googlegroups.com.
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en.

Reply via email to