Reputation: 382
I use NHibernate 3.0 and Postgres 9.0.4. When I'm attempting a new SchemaUpdate(cfg).Execute(scriptAction, true);
nothing happens. No Exceptions, no SQL output (even a provided Action<string> scriptAction
doesn't get called) and no tables created. If I use SchemaExport instead, everything will work like a charm. So I assume that my configurations and mappings are correct.
I read about issues with the combination of NHibernate 2.something.something and Postgres 8.something and the use of SchemaUpdate. Can anyone confirm that SchemaUpdate is still unusable for newer versions of both Postgres and NHibernate, or even better, can anyone guide me to a solution to my problem?
Thanks in advance.
EDIT:
Actually there are exceptions, as I recently found out. SchemaUpdate doesn't throw them, but stores them in its Exceptions property.
I get two System.NotSupportedException
in NHibernate.Dialect.Dialect.GetDataBaseSchema(DbConnection connection)
without additional data, which suggests that SchemaUpdate is not usable with PostgreSQL, but if that would be the case someone already must have found out. I tried both, .PostgreSQLDialect
and .PostgreSQL82Dialect
to no avail.
Upvotes: 4
Views: 1334
Reputation: 1075
you use HBM or FluenetNHibernate Mapping, NHibernate 3.2 solve your problem.
but you use Loquacious Code Mapping in NHibernate 3.2, same problem occurred.
Upvotes: 1
Reputation: 8538
Can you upgrade to the latest release? Looks like the DataProvider / Dialects components got major upgrades for Postgre in NHibernate 3.2.0 GA.
From the release notes:
Build 3.2.0.GA (rev6000)
=============================** Improvement
* [NH-2571] - Full PostgreSQL Support
Not sure if this helps. You're still out of luck if you're using Fluent (latest version works with NH 3.1.0).
UPDATE: Which Fluent source did you use? I just downloaded from Github and it compiled just fine with NH 3.2.0. In fact, the NHibernate section was updated on Aug 11 with message "Updated NHibernate 3.x assemblies to 3.2".
I can't move to the new version yet due to an external assembly depending on NH 3.1.0. What I've done is used SchemaExport.Create( Action<string>, false )
to write the DDL to a text file. I know the mappings that have changed and I manually modify the database to match what NH thinks it should look like. This is ugly, but if you only have a few changes on rare occasions, it's viable.
Upvotes: 2
Reputation: 382
I pretty much answered the question by myself.
A brief examination of nhibernate's source code of version 3.0.0GA reveals that indeed .PostgreSQLDialect
does not override the base class' GetDataBaseSchema(DbConnection connection)
method, hence throwing the System.NotSupportedException
and no IDataBaseSchema
implementor exists for the Postgres dialects. Strange though, that the NHibernate docs do not mention this little detail.
Upvotes: 1