I'm trying to save the values in database. But here I can able to save only once after executing. During second time it shows inner exception as "{"Duplicate entry '' for key 1"}"
A:
Looks like you're assigning the same key to a new object. I mean maybe you're trying to Save a new object in the database with the same key/Id. If you're updating the object with Id/Key = 1 you should use an update command instead.
As Jonny Cundall said we need more information about your NHibernate mapping to see what you're doing...
Do this for you identity:
<!-- Identity mapping -->
<id name="Emp_Id">
<column name="Emp_Id" />
<generator class="native" />
</id>
Advice: do not use string as your data type for an identity column.
Leniel Macaferi
2010-03-30 15:47:28
Here I'm using Id as string. Becoz the id doesn't have only integer values. It contains year of joining, Dept name and Number. So here I used as string. And thanks a lot... Like Genius u guys help us to get more from u.
Siva
2010-03-30 16:19:27