Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

MySQL Hibernate Problem: underscores before table name

  Asked By: Egidius    Date: Jul 06    Category: Java    Views: 8269
  

I have 2 tables "book" & "customer " in the schema "myschema".
but when i try to fetch my data out of my tables, AT FIRST the following exception occured:


Code:
10:55:37,968 ERROR [JDBCExceptionReporter] Table 'myschema.myschema.__book' doesn't exist
10:55:37,968 INFO [STDOUT] org.hibernate.exception.SQLGrammarException: could not execute query using iterate
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:70)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.hql.QueryLoader.iterate(QueryLoader.java:411)
at org.hibernate.hql.ast.QueryTranslatorImpl.iterate(QueryTranslatorImpl.java:281)
at org.hibernate.impl.SessionImpl.iterate(SessionImpl.java:921)
at org.hibernate.impl.QueryImpl.iterate(QueryImpl.java:41)
at com.corp.biz.LibraryManager.getAllBooks(LibraryManager.java:37)


which myschema.myschema.__book seemed so weared. then, i found the problem in the book.hbm.xml file where i emptied the catalog tag as following:

Code:
<hibernate-mapping>
<class name="com.corp.biz.hibernate.mappings.Customer" table="customer" catalog="">
<id name="id" type="java.lang.Integer">


then the exception changed to:

Code:
10:55:37,968 ERROR [JDBCExceptionReporter] Table 'myschema.__book' doesn't exist
10:55:37,968 INFO [STDOUT] org.hibernate.exception.SQLGrammarException: could not execute query using iterate
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:70)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.hql.QueryLoader.iterate(QueryLoader.java:411)
at org.hibernate.hql.ast.QueryTranslatorImpl.iterate(QueryTranslatorImpl.java:281)
at org.hibernate.impl.SessionImpl.iterate(SessionImpl.java:921)
at org.hibernate.impl.QueryImpl.iterate(QueryImpl.java:41)
at com.corp.biz.LibraryManager.getAllBooks(LibraryManager.java:37)


But i still have myschema.__book and at this point, I can't remove the 2 additional underscores from the table name.

I also tried to extend the MySQLDialect class, it already has the code properly, I mean a dot as separator.

I'm using eclipse 3.1
MyEclipse 4.1.1 GA
MySQL 5
Hibernate 3

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Marc Anderson     Answered On: Jul 06

Why do you need the catalog attribute after all, try removing it completely, and watch for more errors, that may guide us in the right direction… Moreover the error is showing table  “__book” is not found, whereas your example mapping is for “customer” table. Also check the resource mapping for “book” table, which might have some errors and remove all “catalog” attributes if that helps.

 
Didn't find what you were looking for? Find more on MySQL Hibernate Problem: underscores before table name Or get search suggestion and latest updates.




Tagged: