NHibernate SchemaUpdate does nothing based on PostgreSQL

I am using NHibernate 3.0 and Postgres 9.0.4. When I try new SchemaUpdate(cfg).Execute(scriptAction, true); , Nothing happens. There are no exceptions, SQL is not thrown (even if the provided Action<string> scriptAction not called), and tables are not created. If I use SchemaExport, everything will work like a charm. Therefore, I assume that my configurations and mappings are correct. I read about problems with a combination of NHibernate 2.something.something and Postgres 8.something using SchemaUpdate. Can someone confirm that SchemaUpdate is still unsuitable for new versions of Postgres and NHibernate, or even better, can someone help me solve my problem?

Thanks in advance.

EDIT:

There are actually exceptions, as I recently found out. SchemaUpdate does not throw them, but stores them in the Exception property. I get two System.NotSupportedException in NHibernate.Dialect.Dialect.GetDataBaseSchema(DbConnection connection) without additional data, which suggests that SchemaUpdate cannot be used with PostgreSQL, but if that is the case, then someone should already figure it out. I tried both .PostgreSQLDialect and .PostgreSQL82Dialect no avail.

+4
source share
3 answers

Can you upgrade to the latest version? It appears that the DataProvider / Dialects components have received major updates for Postgre in NHibernate 3.2.0 GA.

From the release note :

Build 3.2.0.GA (rev6000)
===============================

** Improvement
* [NH-2571] - Full PostgreSQL Support

Not sure if this helps. You are still out of luck if you use Fluent (the latest version works with NH 3.1.0).

UPDATE: What free access source did you use? I just downloaded from Github and compiled with NH 3.2.0. In fact, the NHibernate section was updated on August 11 with the message "NHibernate 3.x builds updated to 3.2."

I can’t upgrade to the new version, but due to the external build depending on NH 3.1.0. What I did is using SchemaExport.Create( Action<string>, false ) to write the DDL to a text file. I know the changes that have changed, and I manually modify the database according to what NH says should look like this. This is ugly, but if in rare cases you only have a few changes, it is viable.

+2
source

I pretty much answered the question myself.

A brief review of the source code for nhibernate version 3.0.0GA shows that indeed .PostgreSQLDialect does not override the base class method GetDataBaseSchema(DbConnection connection) , therefore there is System.NotSupportedException and no IDataBaseSchema for Postgres dialects. It is strange, however, that this is not mentioned in NHibern documents small detail.

+1
source

If you are using HBM or FluenetNHibernate Mapping, NHibernate 3.2 solves your problem.

but you are using Loquacious Code Mapping in NHibernate 3.2, the same problem has occurred.

+1
source

All Articles