NHibernate cascading save

后端 未结 2 943
夕颜
夕颜 2021-01-07 05:22

This is trying to insert null into Comment.BlogArticleID.

The following GenericADOException appeared: \"could not insert: [NHibernate__OneToMany.BO.Comment][SQL: INS

2条回答
  •  悲哀的现实
    2021-01-07 06:09

    The key column of the associated class (Comment.BlogArticleID) must be nullable in the database. NHibernate will insert rows leaving this column NULL and then perform an update to set the key.

    Adding not-null="true" to the key element would not work, as this attribute is only used by the schema export tool.

    Note that the failing insert includes a select for the generated identity for the new child row.

提交回复
热议问题