Re: PostgreSQL Hibernate Problem

Lists: pgsql-general
From: mgazzo <mario(dot)gazzo(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: PostgreSQL Hibernate Problem
Date: 2009-04-27 19:19:17
Message-ID: 23263158.post@talk.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general


I am new to PostgreSQL and I want to use it from a Java Application with the
Hibernate ORM. I ran into a problem when I created my first simple Hello
Postegres app where I receive a 'relation "X" does not exist' error. It
turns out that the query Hibernate produces seems to be missing some quotes
around the table name as in [select mytable0_.id as col_0_0_ from Mytable
mytable0_]. I can reproduce the exact same error with the PgAdmin query tool
when I apply this query string but I it works once I add the quotes as in
[select mytable0_.id as col_0_0_ from "Mytable" mytable0_].

It seems as if Hibernate is not generating the query string properly despite
that the dialect should be set correctly to
org.hibernate.dialect.PostgreSQLDialect. It could also be that I have not
setup my PostgreSQL db correctly for this to work. If anyone has an idea of
a solution to this problem I would be much obliged. I use PostgreSQL 8.3
with Hibernate Entity Manager 3.4.0 GA.
--
View this message in context: http://www.nabble.com/PostgreSQL-Hibernate-Problem-tp23263158p23263158.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


From: Daniel Migowski <dmigowski(at)ikoffice(dot)de>
To: mgazzo <mario(dot)gazzo(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: PostgreSQL Hibernate Problem
Date: 2009-04-28 10:19:19
Message-ID: 49F6D827.9020505@ikoffice.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hello mgazzo,

mgazzo schrieb:
> I am new to PostgreSQL and I want to use it from a Java Application with the
> Hibernate ORM. I ran into a problem when I created my first simple Hello
> Postegres app where I receive a 'relation "X" does not exist' error. It
> turns out that the query Hibernate produces seems to be missing some quotes
> around the table name as in [select mytable0_.id as col_0_0_ from Mytable
> mytable0_]. I can reproduce the exact same error with the PgAdmin query tool
> when I apply this query string but I it works once I add the quotes as in
> [select mytable0_.id as col_0_0_ from "Mytable" mytable0_].
>
> It seems as if Hibernate is not generating the query string properly despite
> that the dialect should be set correctly to
> org.hibernate.dialect.PostgreSQLDialect. It could also be that I have not
> setup my PostgreSQL db correctly for this to work. If anyone has an idea of
> a solution to this problem I would be much obliged. I use PostgreSQL 8.3
> with Hibernate Entity Manager 3.4.0 GA.
>
This problem should be discussed on the Hibernate Mailing list. I can
tell you that it might be possible to extend HibernatePostgreSQLDialect
with your own implementation (I also do it this way in my project) to
add some custom modifications. E.g. the name length is not correct in
Hibernate (states 32, is 64 here).

By the way, please note that PostgreSQL converts every name to
lowercase, and, by enclosing it in quotes, an exact match is to be
found. If you are able to, just use lowercase table names in postgres,
and your problem is solved.

With best regards,
Daniel Migowski


From: mgazzo <mario(dot)gazzo(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: PostgreSQL Hibernate Problem
Date: 2009-04-28 11:41:32
Message-ID: 23275334.post@talk.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general


This solved it. Just renamed my tables with lowercase letters. Thanks a
lot.:clap:

BTW Hibernate forum is currently in maintenance mode and I just tried my
luck here. Sorry about that.

Cheers
Mario

dmigowski wrote:
>
> Hello mgazzo,
>
> mgazzo schrieb:
>> I am new to PostgreSQL and I want to use it from a Java Application with
>> the
>> Hibernate ORM. I ran into a problem when I created my first simple Hello
>> Postegres app where I receive a 'relation "X" does not exist' error. It
>> turns out that the query Hibernate produces seems to be missing some
>> quotes
>> around the table name as in [select mytable0_.id as col_0_0_ from Mytable
>> mytable0_]. I can reproduce the exact same error with the PgAdmin query
>> tool
>> when I apply this query string but I it works once I add the quotes as in
>> [select mytable0_.id as col_0_0_ from "Mytable" mytable0_].
>>
>> It seems as if Hibernate is not generating the query string properly
>> despite
>> that the dialect should be set correctly to
>> org.hibernate.dialect.PostgreSQLDialect. It could also be that I have not
>> setup my PostgreSQL db correctly for this to work. If anyone has an idea
>> of
>> a solution to this problem I would be much obliged. I use PostgreSQL 8.3
>> with Hibernate Entity Manager 3.4.0 GA.
>>
> This problem should be discussed on the Hibernate Mailing list. I can
> tell you that it might be possible to extend HibernatePostgreSQLDialect
> with your own implementation (I also do it this way in my project) to
> add some custom modifications. E.g. the name length is not correct in
> Hibernate (states 32, is 64 here).
>
> By the way, please note that PostgreSQL converts every name to
> lowercase, and, by enclosing it in quotes, an exact match is to be
> found. If you are able to, just use lowercase table names in postgres,
> and your problem is solved.
>
> With best regards,
> Daniel Migowski
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
>

--
View this message in context: http://www.nabble.com/PostgreSQL-Hibernate-Problem-tp23263158p23275334.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.