3

Can Sqlite NHibernate id generator be made compatible with Postgresql? I'm planning to unit test my NHibernate Postgresql project based on this http://ayende.com/Blog/archive/2009/04/28/nhibernate-unit-testing.aspx

If there is no compatible id generator, is there a way to signal NHibernate to ignore id generator when it is using different dialect?

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true" assembly="RuntimeNhibernate" namespace="RuntimeNhibernate" >

  <class name="Blog" table="blog">
    <id name="BlogId" column="blog_id">
        <!-- can this be ignored when using different dialect.. -->
        <generator class="sequence"> 
            <param name="sequence">blog_id_seq</param>
        </generator> 
        <!-- ...can this -->
    </id>


    <property name="AllowsComments" column="allows_comments"/>
    <property name="CreatedAt" column="created_at"/>
    <property name="Subtitle" column="subtitle"/>
    <property name="Title" column="title"/>


  </class>

</hibernate-mapping>  

Error when using Sqlite dialect on Postgresql-specific mapping:

NHibernate.MappingException: could not instantiate id generator: sequence ---> 
NHibernate.MappingException: Dialect does not support sequences

1 Answer 1

1

My suggestion is that you use a DB-agnostic generator, like HiLo.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.