Posted by: joachimvandenbogaert | November 6, 2008

NHibernate and Postgresql: ERROR 42P01

I was setting up NHibernate 2.0.1 with Postgresql 8.3 and Npgsql1.0.1 for .NET 2.0.

I followed the example from the documentation, set up a POCO class and wrote my mapping file correctly, but as it turned out. I kept receiving error 42P01 which states that relation “n” does not exist.

The error had nothing to do with a non-existent table, but with a configuration file example on:

http://www.hibernate.org/361.html#A6

The solution to the problem is on the same page (if you look well enough, that is):

http://www.hibernate.org/361.927.html

The connection string should read “database=” instead of “initial catalog=”
Unfortunately the example has not been updated at the time of writing.

So here is a corrected version

<?xml version=”1.0″ encoding=”utf-8″?>
<hibernate-configuration  xmlns=”urn:nhibernate-configuration-2.2″ >
    <session-factory name=”NHibernate.Test”>
        <property name=”connection.provider”>NHibernate.Connection.DriverConnectionProvider</property>
        <property name=”connection.driver_class”>NHibernate.Driver.NpgsqlDriver</property>
        <property name=”connection.connection_string”>
            Server=localhost;database=nhibernate;User ID=nhibernate;Password=********;
        </property>
        <property name=”dialect”>NHibernate.Dialect.PostgreSQLDialect</property>
    </session-factory>
</hibernate-configuration>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: