Null Index Column Exception when mapping List

1,353 views
Skip to first unread message

HMS

unread,
May 19, 2009, 9:38:24 AM5/19/09
to Fluent NHibernate
Hello,

I'm running into the following problems while mapping a List of
objects using List semantics, I can't use a bag because the order is
important.

However when testing I get the following exception:

NHibernate.HibernateException: null index column for collection:
SubPhases.

The mapping looks like this:

HasMany(p => p.SubPhases)
.Inverse()
.KeyColumnNames.Add("ParentPhase")
.AsList(index => index.WithColumn("idx"))
.Cascade.AllDeleteOrphan();

I've also tried

.AsList() and AsList(index => index.WithColumn("idx").WithType<int>())

both without success.

Am I missing something obvious ?

Thanks :)

- HMS

Stuart Childs

unread,
May 19, 2009, 10:12:55 AM5/19/09
to fluent-n...@googlegroups.com
This is an NHibernate issue and I'm not 100% sure, but the error
message implies to me that you have a null value in your index column.
NHibernate requires your index column to be integer values starting at
zero.

However, export the mappings FNH is generating to be sure it's not an
issue with the HBM generation.

Enzo

unread,
Jun 30, 2009, 7:06:49 PM6/30/09
to Fluent NHibernate
I recently had the same issue so maybe I can help...
Does the generated mapping include a inverse="true" on the list you're
having this issue with?
If so, try to make this end (and not the many-to-one) manage the
association by setting inverse="false"
and on the other end insert="false" and update="false".

Hope this helps, Peter.

On 19 Mag, 16:12, Stuart Childs <chil...@gmail.com> wrote:
> This is an NHibernate issue and I'm not 100% sure, but the error  
> message implies to me that you have a null value in your index column.  
> NHibernate requires your index column to be integer values starting at  
> zero.
>
> However, export the mappings FNH is generating to be sure it's not an  
> issue with the HBM generation.
>
> Le May 19, 2009 à 8:38 AM, HMS <jvander...@gmail.com> a écrit :
>
>
>
>
>
> > Hello,
>
> > I'm running into the following problems while mapping a List of
> > objects using List semantics, I can't use a bag because the order is
> > important.
>
> > However when testing I get the following exception:
>
> > NHibernate.HibernateException: null index column for collection:
> > SubPhases.
>
> > The mapping looks like this:
>
> >            HasMany(p => p.SubPhases)
> >                .Inverse()
> >                .KeyColumnNames.Add("ParentPhase")
> >                .AsList(index => index.WithColumn("idx"))
> >                .Cascade.AllDeleteOrphan();
>
> > I've also tried
>
> > .AsList() and AsList(index => index.WithColumn("idx").WithType<int>())
>
> > both without success.
>
> > Am I missing something obvious ?
>
> > Thanks :)
>
> > - HMS- Nascondi testo citato
>
> - Mostra testo citato -
Reply all
Reply to author
Forward
0 new messages