使用SQLite进行NHibernate和Postgresql的单元测试。序列生成器问题。

3
可以将Sqlite NHibernate id生成器与Postgresql兼容吗?我计划基于此对我的NHibernate Postgresql项目进行单元测试。如果没有兼容的id生成器,是否有办法在使用不同方言时通知NHibernate忽略id生成器?http://ayende.com/Blog/archive/2009/04/28/nhibernate-unit-testing.aspx

<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>  

使用Sqlite方言时在Postgresql特定映射上出现错误:
NHibernate.MappingException: could not instantiate id generator: sequence ---> 
NHibernate.MappingException: Dialect does not support sequences
1个回答

1

我的建议是您使用一个数据库无关的生成器,例如 HiLo


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接