-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: keep on getting Table 'test.__CAT' does't exist (Hibernate3)
PostPosted: Thu Apr 07, 2005 3:11 am 
Newbie

Joined: Thu Apr 07, 2005 2:55 am
Posts: 4
I'm using the Hibernate Console using Hibernate 3.0, Eclipse 3.1 M6, tools-3.0alpha1,mysql-connector-java-3.1.7, MySQL 4.0.1

I am new to Hibernate, and just want to try to access my database using the generated objects, with the typical example CAT table, and using the GUI provides by hibernatetools.

What is working? When I tried to get a java.sql.Connection from session.connection. I can access my database with standard JDBC calls. For some reason the generated sql from hibernate tries to access 'test.__CAT' and i get the exception below.

Does anybody know what I might be missing?

Hibernate version: 3.0

Mapping documents:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="sessionFactory">
<property name="hibernate.connection.url">jdbc:mysql://localhost/test</property>
<property name="hibernate.cglib.use_reflection_optimizer">true</property>
<property name="hibernate.connection.password">xxxx</property>
<property name="hibernate.connection.username">xxxx</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<mapping resource="hbmtest/Cat.hbm.xml" />
</session-factory>
</hibernate-configuration>


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<!--
Auto-generated mapping file from
the hibernate.org cfg2hbm engine
-->
<class name="hbmtest.Cat" table="CAT" catalog="">
<id name="CatId" type="java.lang.Character">
<column name="cat_id" scale="32" precision="0" not-null="true" unique="true" sql-type="char" />
<generator class="assigned" />
</id>
<property name="Name" type="java.lang.Character">
<column name="name" scale="16" precision="0" not-null="true" sql-type="char" />
</property>
<property name="Sex" type="java.lang.Character">
<column name="sex" scale="1" precision="0" not-null="true" sql-type="char" />
</property>
<property name="Weight" type="java.lang.Double">
<column name="weight" scale="22" precision="0" not-null="true" sql-type="double" />
</property>
</class>
</hibernate-mapping>



Code between sessionFactory.openSession() and session.close():

Not Applicable



Full stack trace of any exception that occurs:

org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:70)
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:268)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:788)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at org.hibernate.console.HQLQueryPage.getList(HQLQueryPage.java:30)
at org.hibernate.eclipse.console.views.QueryPageViewer$ContentProviderImpl.getElements(QueryPageViewer.java:80)
at org.eclipse.jface.viewers.StructuredViewer.getRawChildren(StructuredViewer.java:765)
at org.eclipse.jface.viewers.TableViewer.getRawChildren(TableViewer.java:1046)
at org.eclipse.jface.viewers.StructuredViewer.getFilteredChildren(StructuredViewer.java:707)
at org.eclipse.jface.viewers.StructuredViewer.getSortedChildren(StructuredViewer.java:822)
at org.eclipse.jface.viewers.TableViewer.internalRefreshAll(TableViewer.java:762)
at org.eclipse.jface.viewers.TableViewer.internalRefresh(TableViewer.java:712)
at org.eclipse.jface.viewers.TableViewer.internalRefresh(TableViewer.java:701)
at org.eclipse.jface.viewers.StructuredViewer$7.run(StructuredViewer.java:1171)
at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1108)
at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:1169)
at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:1128)
at org.eclipse.jface.viewers.TableViewer.inputChanged(TableViewer.java:662)
at org.eclipse.jface.viewers.ContentViewer.setInput(ContentViewer.java:248)
at org.eclipse.jface.viewers.StructuredViewer.setInput(StructuredViewer.java:1324)
at org.hibernate.eclipse.console.views.QueryPageViewer.createTable(QueryPageViewer.java:174)
at org.hibernate.eclipse.console.views.QueryPageViewer.createControl(QueryPageViewer.java:153)
at org.hibernate.eclipse.console.views.QueryPageViewer.<init>(QueryPageViewer.java:111)
at org.hibernate.eclipse.console.views.QueryPageTabView.rebuild(QueryPageTabView.java:83)
at org.hibernate.eclipse.console.views.QueryPageTabView$1.contentsChanged(QueryPageTabView.java:52)
at org.hibernate.eclipse.console.views.QueryPageTabView$1.intervalAdded(QueryPageTabView.java:57)
at javax.swing.AbstractListModel.fireIntervalAdded(AbstractListModel.java:130)
at org.hibernate.console.QueryPageModel.add(QueryPageModel.java:50)
at org.hibernate.console.KnownConfigurations$3.queryPageCreated(KnownConfigurations.java:167)
at org.hibernate.console.ConsoleConfiguration.fireQueryPageCreated(ConsoleConfiguration.java:266)
at org.hibernate.console.ConsoleConfiguration.executeHQLQuery(ConsoleConfiguration.java:247)
at org.hibernate.eclipse.console.views.KnownConfigurationsView$5.run(KnownConfigurationsView.java:143)
at org.hibernate.eclipse.console.views.KnownConfigurationsView$3.doubleClick(KnownConfigurationsView.java:91)
at org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredViewer.java:637)
at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1021)
at org.eclipse.core.runtime.Platform.run(Platform.java:757)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:40)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:148)
at org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(StructuredViewer.java:635)
at org.eclipse.jface.viewers.StructuredViewer.handleDoubleSelect(StructuredViewer.java:857)
at org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSelected(StructuredViewer.java:964)
at org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEvent(OpenStrategy.java:219)
at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.java:216)
at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:275)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1012)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2778)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2472)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1570)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1534)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:306)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:103)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:228)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:156)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:315)
at org.eclipse.core.launcher.Main.basicRun(Main.java:268)
at org.eclipse.core.launcher.Main.run(Main.java:942)
at org.eclipse.core.launcher.Main.main(Main.java:926)
Caused by: java.sql.SQLException: Table 'test.__CAT' doesn't exist
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2847)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1531)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1622)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2376)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2297)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1860)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1705)
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)
... 65 more




Name and version of the database you are using:

MySQL 4.0.10

mysql> desc CAT;
+--------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+----------+------+-----+---------+-------+
| cat_id | char(32) | | PRI | | |
| name | char(16) | | | | |
| sex | char(1) | | | | |
| weight | double | | | 0 | |
+--------+----------+------+-----+---------+-------+
4 rows in set (0.00 sec)




The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 07, 2005 4:06 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
fixed in alpha 2, available from jboss ide download page.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 07, 2005 3:02 pm 
Newbie

Joined: Thu Apr 07, 2005 2:55 am
Posts: 4
I've updated to alpha 2, and I'm still getting the error... here's what I get still... wonder what can be wrong?

----------------------------------------------

Exception while executing HQL Query

eclipse.buildId=I20050401-1645
java.version=1.4.2_06
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Command-line arguments: -os win32 -ws win32 -arch x86


------------------------------------------------

java.sql.SQLException: Table 'test.__CAT' doesn't exist
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2847)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1531)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1622)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2376)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2297)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1860)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1705)
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)
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:268)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:788)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at org.hibernate.console.HQLQueryPage.getList(HQLQueryPage.java:30)
at org.hibernate.eclipse.console.views.QueryPageViewer$ContentProviderImpl.getElements(QueryPageViewer.java:80)
at org.eclipse.jface.viewers.StructuredViewer.getRawChildren(StructuredViewer.java:765)
at org.eclipse.jface.viewers.TableViewer.getRawChildren(TableViewer.java:1046)
at org.eclipse.jface.viewers.StructuredViewer.getFilteredChildren(StructuredViewer.java:707)
at org.eclipse.jface.viewers.StructuredViewer.getSortedChildren(StructuredViewer.java:822)
at org.eclipse.jface.viewers.TableViewer.internalRefreshAll(TableViewer.java:762)
at org.eclipse.jface.viewers.TableViewer.internalRefresh(TableViewer.java:712)
at org.eclipse.jface.viewers.TableViewer.internalRefresh(TableViewer.java:701)
at org.eclipse.jface.viewers.StructuredViewer$7.run(StructuredViewer.java:1171)
at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1108)
at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:1169)
at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:1128)
at org.eclipse.jface.viewers.TableViewer.inputChanged(TableViewer.java:662)
at org.eclipse.jface.viewers.ContentViewer.setInput(ContentViewer.java:248)
at org.eclipse.jface.viewers.StructuredViewer.setInput(StructuredViewer.java:1324)
at org.hibernate.eclipse.console.views.QueryPageViewer.createTable(QueryPageViewer.java:174)
at org.hibernate.eclipse.console.views.QueryPageViewer.createControl(QueryPageViewer.java:153)
at org.hibernate.eclipse.console.views.QueryPageViewer.<init>(QueryPageViewer.java:111)
at org.hibernate.eclipse.console.views.QueryPageTabView.rebuild(QueryPageTabView.java:83)
at org.hibernate.eclipse.console.views.QueryPageTabView$1.contentsChanged(QueryPageTabView.java:52)
at org.hibernate.eclipse.console.views.QueryPageTabView$1.intervalAdded(QueryPageTabView.java:57)
at javax.swing.AbstractListModel.fireIntervalAdded(Unknown Source)
at org.hibernate.console.QueryPageModel.add(QueryPageModel.java:50)
at org.hibernate.console.KnownConfigurations$3.queryPageCreated(KnownConfigurations.java:167)
at org.hibernate.console.ConsoleConfiguration.fireQueryPageCreated(ConsoleConfiguration.java:266)
at org.hibernate.console.ConsoleConfiguration.executeHQLQuery(ConsoleConfiguration.java:247)
at org.hibernate.eclipse.console.views.KnownConfigurationsView$5.run(KnownConfigurationsView.java:143)
at org.hibernate.eclipse.console.views.KnownConfigurationsView$3.doubleClick(KnownConfigurationsView.java:91)
at org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredViewer.java:637)
at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1021)
at org.eclipse.core.runtime.Platform.run(Platform.java:757)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:40)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:148)
at org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(StructuredViewer.java:635)
at org.eclipse.jface.viewers.StructuredViewer.handleDoubleSelect(StructuredViewer.java:857)
at org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSelected(StructuredViewer.java:964)
at org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEvent(OpenStrategy.java:219)
at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.java:216)
at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:275)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2894)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2527)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1570)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1534)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:306)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:103)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:228)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:156)
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 org.eclipse.core.launcher.Main.invokeFramework(Main.java:315)
at org.eclipse.core.launcher.Main.basicRun(Main.java:268)
at org.eclipse.core.launcher.Main.run(Main.java:942)
at org.eclipse.core.launcher.Main.main(Main.java:926)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 07, 2005 4:25 pm 
Newbie

Joined: Fri Apr 01, 2005 2:34 pm
Posts: 1
Try removing the catalog="" attribute in the class element of the mapping file.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 07, 2005 5:00 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
freaking hey - are catalog and schema STILL being generated in the hbm.xmls when using mysql ?

...can someone verify this on a alpha 2 run ?

/max

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 07, 2005 5:32 pm 
Newbie

Joined: Thu Apr 07, 2005 2:55 am
Posts: 4
This is my generated Cat.hbm.xml, after using alpha 2. The catolog="" attribute is there, in the class element.

--------------------------------------------------------------------

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<!--
Auto-generated mapping file from
the hibernate.org cfg2hbm engine
-->
<class name="hbm.Cat" table="CAT" catalog="">
<id name="CatId" type="java.lang.String">
<column name="cat_id" scale="32" precision="0" not-null="true" sql-type="varchar" />
<generator class="assigned" />
</id>
<property name="Name" type="java.lang.String">
<column name="name" scale="16" precision="0" not-null="true" sql-type="varchar" />
</property>
<property name="Sex" type="java.lang.Character">
<column name="sex" scale="1" precision="0" not-null="false" sql-type="char" />
</property>
<property name="Weight" type="java.lang.Double">
<column name="weight" scale="22" precision="0" not-null="false" sql-type="double" />
</property>
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 07, 2005 5:36 pm 
Newbie

Joined: Thu Apr 07, 2005 2:55 am
Posts: 4
pty,

removing the catalog="" helped!

Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.