nhibernate(或 hibernate)条件级联
我有一个 User 类,它有一个属性 Event,它有很多会话。基本上,用户注册一个有很多会话时间的活动。
用户可以注册参加活动,但会议时间仅供参考。
但是当我使用 NH 将用户写入数据库时,它也会更新会话时间。我怎样才能防止这种情况发生,因为我知道在创建/更新活动时仍然需要插入/更新会话时间。
I have a class User, that has a property Event, which has many Sessions. Basically, a user register to an event which have many sessions hours.
The user can register for an event, but the sessions hours are purely informative.
But when I write a user to the database with NH, it updates the sessions hours too. How can I prevent that, knowing that I still need the sessions hours to be inserted/updated when I create/update an event.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能并不完全适用于您的问题,但我遇到了一些问题,我想根据某些业务规则有条件地级联删除。
很多时候,您可以在持久性逻辑中处理这个问题。我遇到过一个使用 NHibernate 事件监听器的案例。
This might not totally apply to your question, but I've had issues where I wanted to conditionally cascade deletes based on certain business rules.
A lot of the times, you can handle this in your persistence logic. I had a case where I went with NHibernate Event Listeners.