rest - How do I get NHibernate to save an entity if I assign it an ID, but generate one otherwise? -
according rest philosophy, put
request should update resource @ url if exists, , create if doesn't exist. in other words, if use following url:
put http://server/item/5
if item
exists id of 5, updated. if item
doesn't exist id of 5, new item
created id of 5.
however, i'm using nhibernate persistence, , mapped ids identity
. means no matter value assign id, nhibernate replace own when save new item
.
how nhibernate save item
id assign it, without changing id mapping assigned
?
if use identity, db won't allow enter value.
that said, if db has special syntax allow inserting explicit values in identity fields, can implement own generator, guarantee error prone, hard debug, , not useful. it's possible.
study in https://nhibernate.svn.sourceforge.net/svnroot/nhibernate/trunk/nhibernate/src/nhibernate/id , start creating frankenstein :-)
Comments
Post a Comment