使用 NHibernate / Fluent Nhibernate 强制进行身份插入
我们有一个使用 NHibernate 的相当强大的系统,我们正在从单个数据库服务器迁移到两台服务器,一台用于管理,一台用于我们面向公众的网站。这主要是为了我们可以使用不会影响当前站点的工作流程来执行内容管理之类的操作。截至今天,它们是同一服务器中的两个数据库,但随着时间的推移,我可以看到使用两台物理机通过 Web 服务调用来推送数据。
举个例子,我们的一位营销人员决定通过管理员推出一项新的促销活动,并将其安排在从现在起的两周内。我们正在开发一个调度系统,该系统将在新促销活动开始时将其推送到我们的生产服务器。目的是使用相同的 NHibernate 提供程序进行数据推送,但我们需要保持引用完整性。
我们使用的是 Fluent nhibernate,我可以看到编写两个不同的类映射,然后使用某种形式的依赖注入(IE 结构映射)来选择要加载的映射。我希望得到更好的答案,因为随着系统的增长,这似乎不可能维持。有什么建议吗?
We have a fairly robust system using NHibernate, we're in the middle of migrating from a single database server to having two servers, one for administration and one for our public facing web site. This is mainly so that we can do things like content management with workflow that won’t affect the current site. As of today, they are two databases in the same server, but over time I can see using two physical machines with a web service call to push data.
So as an example, one of our marketing guys decides to introduce a new promotion through the admin , and schedule it for 2 weeks from now. We are working on a scheduling system that would push the new promotion to our production server when it’s kicked off. The intent was to use the same NHibernate providers for the data pushes, but we need to maintain referential integrity.
We’re using fluent nhibernate, and I can see writing two different class maps, and then using a some form of dependency injection ( IE structure map) of choosing which map to load. I was hoping for a better answer as that seems impossible to maintain as the system grows. Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
数据库生成的 ID 值不支持 ISession.Replicate。正如 NHibernate 问题跟踪器中的此问题所示。
生成器或 Guid/Guid.Comb 自
你将能够使用 NHibernate 的
在这种情况下复制(如
在问题中解释)
ISession.Replicate is not supported with DB generated ID values. As illustrated by this issue in the NHibernate issue tracker.
generator or Guid/Guid.Comb since
you'll be able to use NHibernate's
replication in that case (as
explained in the issue)