NHibernate +多对多包 +映射表
我有以下3节课。
BusinessStream
Scheme
Bus_Stream_Scheme_Map
当我尝试执行 transaction.Commit()
方法时,在 BusinessStream
的 session.SaveOrUpdate()
之后,出现以下错误,
无法插入 NULL进入(“DBO”。“BUS_STREAM_SCHEME_MAP”。“BUS_STREAM_SCHEME_MAP_ID”)
HBM 文件,
BusienssStream
<class name="BusinessStream" table="BUS_STREAM">
<id name="Id" column="BS_ID" type="Int32" >
<generator class="sequence">
<param name="sequence">BUS_STREAM_SEQ</param>
</generator>
</id>
<property name="Name" column="Name" type="String"/>
<property name="Description" column="Description" type="String"/>
<bag name="Schemes" table="BUS_STREAM_SCHEME_MAP" lazy="false">
<key column="BUS_STREAM_ID"></key>
<many-to-many class="Scheme" column="SCHEME_ID"></many-to-many>
</bag>
</class>
方案
<class name="Scheme" table="SCHEME_DEF">
<id name="Id">
<column name="SCHEME_ID"/>
<generator class="native">
<param name="sequence">SCHEME_DEF_SEQ</param>
</generator>
</id>
<property name="Description" column="SCHEME_DESC" type="String"/>
</class>
BusinessStream_Scheme_Map
<class name="BusinessStreamSchemeMapping" table="BUS_STREAM_SCHEME_MAP">
<id name="Id">
<column name="BUS_STREAM_SCHEME_MAP_ID"/>
<generator class="native">
<param name="sequence">BUS_STREAM_SCHEME_MAP_SEQ</param>
</generator>
</id>
</class>
我做错了什么?
I have following 3 classes.
BusinessStream
Scheme
Bus_Stream_Scheme_Map
When I try to execute transaction.Commit()
method, after session.SaveOrUpdate()
for BusinessStream
, I get following error,
cannot insert NULL into ("DBO"."BUS_STREAM_SCHEME_MAP"."BUS_STREAM_SCHEME_MAP_ID")
HBM Files,
BusienssStream
<class name="BusinessStream" table="BUS_STREAM">
<id name="Id" column="BS_ID" type="Int32" >
<generator class="sequence">
<param name="sequence">BUS_STREAM_SEQ</param>
</generator>
</id>
<property name="Name" column="Name" type="String"/>
<property name="Description" column="Description" type="String"/>
<bag name="Schemes" table="BUS_STREAM_SCHEME_MAP" lazy="false">
<key column="BUS_STREAM_ID"></key>
<many-to-many class="Scheme" column="SCHEME_ID"></many-to-many>
</bag>
</class>
Scheme
<class name="Scheme" table="SCHEME_DEF">
<id name="Id">
<column name="SCHEME_ID"/>
<generator class="native">
<param name="sequence">SCHEME_DEF_SEQ</param>
</generator>
</id>
<property name="Description" column="SCHEME_DESC" type="String"/>
</class>
BusinessStream_Scheme_Map
<class name="BusinessStreamSchemeMapping" table="BUS_STREAM_SCHEME_MAP">
<id name="Id">
<column name="BUS_STREAM_SCHEME_MAP_ID"/>
<generator class="native">
<param name="sequence">BUS_STREAM_SCHEME_MAP_SEQ</param>
</generator>
</id>
</class>
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这只是一个猜测,但是如果您将 BUS_STREAM_SCHEME_MAP_ID 设置为自动递增字段,它会起作用吗?
This is just a guess, but would it work if you set
BUS_STREAM_SCHEME_MAP_ID
to be an auto-incrementing field?