Reputation: 8115
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
Upvotes: 3
Views: 1313
Reputation: 52745
My suggestion is that you use a DB-agnostic generator, like HiLo
.
Upvotes: 1