Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8211487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:26:33+00:00 2026-06-07T10:26:33+00:00

we are currently evaluating whether nHibernate supports the requirements for our project. We share

  • 0

we are currently evaluating whether nHibernate supports the requirements for our project. We share the database with another application so that we are not completely free as regards changes to the schema.
Some columns are filled with unique and consecutive numbers (e.g. for invoices). The next number is determined by a stored procedure that also implements a locking algorithm so that the numbers are guaranteed to be consecutive.
On the one hand we could define a trigger on the respective tables that sets the value for the column when an empty or special value is provided. This would require changing the existing database definition – though it might be the most reliable way to implement this.
In order to avoid the change of the database definition we are trying to solve this in the nHibernate ORM. We’ve first tried to implement a user type that calls the stored procedure in NullSafeSet if an empty value is provided. Unfortunately, the connection and transaction of the provided command are not set yet when NullSafeSet is called.

How can we solve this with nHibernate?

Thanks in advance,

Markus

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:26:36+00:00Added an answer on June 7, 2026 at 10:26 am

    If you decide to go with trigger route, then you’ll need to add generated attribute to your property mapping.

    Generated properties are properties which have their values generated
    by the database. Typically, NHibernate applications needed to Refresh
    objects which contain any properties for which the database was
    generating values. Marking properties as generated, however, lets the
    application delegate this responsibility to NHibernate. Essentially,
    whenever NHibernate issues an SQL INSERT or UPDATE for an entity which
    has defined generated properties, it immediately issues a select
    afterwards to retrieve the generated values.

    Aside from that, I’m not quite sure how would you call stored procedure from NHibernate issued INSERT, without adding a trigger or default constraint on column.


    Edit

    Looks like NHibernate has a notion of class persisters, through the interface IEntityPersister. Maybe you could hack something out from that.

    The persister attribute lets you customize the persistence strategy
    used for the class. You may, for example, specify your own subclass of
    NHibernate.Persister.EntityPersister or you might even provide a
    completely new implementation of the interface
    NHibernate.Persister.IClassPersister that implements persistence via,
    for example, stored procedure calls, serialization to flat files or
    LDAP. See NHibernate.DomainModel.CustomPersister for a simple example
    (of “persistence” to a Hashtable).

    You could start from NHibernate’s source.

    If you have the ability to add triggers to database, that would probably be the best, straightforward way, without investing too much time to fight with NHibernate’s internals.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are currently evaluating Liferay for our non-profit organization, and there's one concern that
I'm currently evaluating the technologies we want to use for our next project. It
I am currently evaluating grid components for our new portal project. I came across
I'm currently evaluating the use of ADO.NET for a C++ application that currently uses
I'm currently evaluating Hadoop 1.0.2 for an in-house project. The Hadoop docs say that
I am currently evaluating for an eCommerce project. Is there any good Python based
I am currently evaluating IntelliJ for a tapestry project. I setup my module to
we are currently evaluating JPA for our persistence unit and we got a problem
Currently we are evaluating whether it is possible to provide rsync support to an
We are currently evaluating different applications that interface with Visual Studio 2008 (C#) and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.