English 中文(简体)
Forcing an identity insert with NHibernate / Fluent Nhibernate
原标题:

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?

最佳回答

ISession.Replicate is not supported with DB generated ID values. As illustrated by this issue in the NHibernate issue tracker.

  • I suggest either to use your own ID generator or Guid/Guid.Comb since you ll be able to use NHibernate s replication in that case (as explained in the issue)
  • You can also write your own replication code which does not use NHibernate, if it s simple enough this is doable.
  • Use replication technology that your DB supports. I ve used replication between MS SQL Servers before, and it s not that hard to set up. I m quite sure other RDBMS s support similar stuff.
问题回答

暂无回答




相关问题
nHibernate one-to-many inserts but doesnt update

Instead of getting into code, I have a simple question. Default behavior for a simple one-to-many is that it inserts the child record then updates the foreign key column with the parent key. Has ...

How Do I copy an existing nhibernate object as a new object?

I a persisted NHibernate object that I would like to repersist as a new entity. How do I get NHibernate to save this object as if it was a new? I am thinking I might create a session interceptor to ...

join across databases with nhibernate

I am trying to join two tables that reside in two different databases. Every time, I try to join I get the following error: An association from the table xxx refers to an unmapped class. If the ...

WPF - MVVM - NHibernate Validation

Im facing a bit of an issue when trying to validate a decimal property on domain object which is bound to a textbox on the view through the viewmodel. I am using NHibernate to decorate my property on ...

NHibernate Search in a List using ICriteria

I have my class X : public class ClassX { public virtual IList<ClassY> ListY { get; set; } ... } My ClassX mapping (using Fluent) ... HasMany<ClassX>(x => x.ListY ) ....

热门标签