Hibernate is generating queries without quoting table and column names so the PostgreSQL JDBC driver reports ERROR: relation "<tablename>" does not exist. I am using the most up to date JDBC driver and I have all required hibernate dependencies included (as listed in lib/README.txt).
I must have something misconfigured - but what? Any ideas?
cheers,
merlyn
Hibernate version: 3.0.2
hibernate.cfg.xml:
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="show_sql">true</property>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.url">jdbc:postgresql://localhost/TestDb</property>
<property name="hibernate.connection.username">postgres</property>
<property name="hibernate.connection.password">xxx</property>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="hibernate.connection.pool_size">4</property>
<mapping resource="es/novasoft/model/hibernate/MenMenu.hbm.xml"/>
<mapping resource="es/novasoft/model/hibernate/MentMenu.hbm.xml"/>
<mapping resource="es/novasoft/model/hibernate/IdiIdioma.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Mapping documents: (can post if required)
Code between sessionFactory.openSession() and session.close():
Query query = session.createQuery("SELECT menu FROM MenMenu menu");
List list = query.list();
Full stack trace of any exception that occurs:
org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:59)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:1518)
at org.hibernate.loader.Loader.list(Loader.java:1498)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:369)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:266)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:788)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at es.novasoft.prototype.controller.HibernateTest.testHibernate(HibernateTest.java:31)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:436)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:311)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.sql.SQLException: ERROR: relation "men_menu" does not exist
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1471)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1256)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:175)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:388)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:329)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:239)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:118)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1197)
at org.hibernate.loader.Loader.doQuery(Loader.java:366)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:206)
at org.hibernate.loader.Loader.doList(Loader.java:1515)
... 21 more
Name and version of the database you are using:
PostgreSQL 8.0.2
The generated SQL (show_sql=true):
select menmenu0_.MEN_PK as MEN1_, menmenu0_.TMN_PK as TMN2_0_, menmenu0_.MEN_NIVEL as MEN3_0_, menmenu0_.MEN_ORDEN as MEN4_0_, menmenu0_.MEN_HOJA_SN as MEN5_0_, menmenu0_.MEN_DESTACADO as MEN6_0_, menmenu0_.MEN_MEN_PK as MEN7_0_ from MEN_MENU menmenu0_
Debug level Hibernate log excerpt: (not posted)
|