How do you create a list collection in NHibernate with a non-nullable index? -


i'm using fluentnhibernate map bi-directional one-to-many relationship ordering important, i'm using list:

        hasmany(x => x.children)             .aslist(index => index.column("child_index"))             .keycolumn("parent_id")             .not.lazyload()             .access.camelcasefield()             .cascade.alldeleteorphan(); 

on other side, it's mapped this:

        references(x => x.parent)             .column("parent_id")             .not.nullable()             .fetch.join()             .not.lazyload()             .cascade.saveupdate(); 

now in actual database, child_index column not nullable. however, when nhibernate persists child elements during insert, doesn't insert child_index column. performs update set child_index. odd me, has index value when insert.

is there way tell nhibernate write index column during insert?

bidirectional indexed collections (i.e. lists , dictionaries) not supported.

since required avoid inserting null , updating (see note in 6.4. one-to-many associations), workaround use bag instead of list , create regular index property in many side.

you can wrap collection manipulation deal both sides' references , indexes.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -