I've developed an application that uses NHibernate. The problem is that the application is performed 2 times at the same time, so there are 2 instances running at the same time in the same machine under the same user (I'm running the application using 2 Terminal Sessions).
The problem is, when I'm trying to create a Entity in one instance application, for example, an article, the NHibernate generates and Id value, for example 12,
Code:
<class name="Model.Entities.ComplexArticle, Model" table="ARTICLE">
<id name="Id" column="ID" type="Int32" unsaved-value="-1">
<generator class="increment"/>
</id>
If I create an article in the other instance application, the NHibernate generates 13 identificator value, ... But, the problem appears when if, now I use the first application in other to create an other article, the NHibernate, generates 13 identificator value!! So, when I create this last article, I'm inserting an article into database that already exists.
How Can I to solve this problem?
I will appreciate a lot your help.
Code:
NHibernate.ISession session = this.session_factory.OpenSession();
NHibernate.ITransaction tx = session.BeginTransaction();
Model.Entities.ComplexArticle article = new Model.Entities.ComplexArticle(...);
session.SaveOrUpdate(article);
tx.Commit();
session.close();
Thanks for all in advance.