I use NHibernate with the Repository-Pattern. The Repositories has the Methods Insert() and Update(). Now, Insert() call Session.Save(entity) and Update() call Session.Merge(entity). My Entities has for the PrimaryKey the fallowing mapping:
<id name="Id" column="TBADRPERSON_ID" type="Int32" unsaved-value="0">
<generator class="assigned"/>
</id>
The id is assigned from me. Now, Session.Save(entity) is first performing an Select to see, if the Entity is new or already exisiting. But in the Insert()-Case the entity is always new. I am searching now a way to tell NHibernate to always do an Insert - instead first a Select and then an Insert. I have seen, that I could do this with a Version-Property - but I cannot change the Database-Schema.
Thanks for any help.
If you want to always save, maybe you can try :
<id name="Id" column="TBADRPERSON_ID" type="Int32" unsaved-value="any">
<generator class="assigned"/>
</id>
Then do a Session.SaveOrUpdate() for Insert(), and a Session.Merge() then Session.SaveOrUpdate() for Update()