kokoness wrote:
What's the common/best approach for determining if a certain record already exists? Given the table has a primary key. I'd like to check first if the data is not existing before I insert one.
I'm new to nhibernate. I've just done a simple mapping and data retrieval with this using c#. Normally w/o nhibernate, I'll create a stored procedure like doesUserExist. But with nhibernate, what approach is done?
Thanks.
You would do something similar to what you've done in the past, except that instead of using a stored procecure, you would use an NHiberanate query. There is the option of using an ICriteria query, or you can develop an HQL query.
If you are using the Primary Key as your search criteria you can issue a Session.Load(...) statement. If the object doesn't exist I would expect it to return null.
Hope this helps.