-->
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.  [ 5 posts ] 
Author Message
 Post subject: HQL in Hibernate tool Eclipse IDE 3.1 doesn't work...
PostPosted: Wed Oct 26, 2005 2:44 pm 
Beginner
Beginner

Joined: Sun Oct 16, 2005 12:37 pm
Posts: 47
Location: Romania, Galati
[color=red]I am new in Hibernate 3.0 and I am an Eclipse 3.1 user. I've installed the latest version of Hibernate Tool (JBossIDE-1.5RC1-ALL.zip) on Eclipse IDE 3.1. First I use new wizard Hibernate Configuration File, then I create a hibernate configuration console and named it Merp. This appear in Hibernate Configuration View from Hibernate Console Perspective. The I use Hibernate artifact generator for reversing from database. I do all these stuff as I read from Hibernate tool's documentation on web. All worked fine and configure file with all new mapping resources, mapping files, model classes and even DAO classes ware generated into right place and correct. After a full compile and I've created new session factory, all this stuff are there and even metadata from database connection. But when I try to use HQL scratchpad I obtain nothing but a exception. The whole stacktrace I put in this topic. Is strange how merp_ appear...

Schema is merp and table is personal. But from where appear merp_??
Why HQL generator looks for 'merp.merp_personal' table instead of 'merp.personal'. Database server is mysql-4.1.7, jdbc driver is mysql-connector-java-3.0.14-production-bin.jar and choosen Hibernate dialect is org.hibernate.dialect.MySQLDialect

HQL query is 'from Personal'

I note the auto-complite for entities but properties for entity are not auto-complited in HQL editor.


any help is welcome, thx[/color]

Error 2005-10-26 21:01:35.857 java.sql.SQLException: Base table or view not found, message from server: "Table 'merp.merp_personal' doesn't exist"
java.sql.SQLException: Base table or view not found, message from server: "Table 'merp.merp_personal' doesn't exist"
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1977)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1163)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1272)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2236)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1555)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:137)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1676)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:223)
at org.hibernate.loader.Loader.doList(Loader.java:2147)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2026)
at org.hibernate.loader.Loader.list(Loader.java:2021)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:369)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:296)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:992)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at org.hibernate.console.HQLQueryPage.getList(Unknown Source)
at org.hibernate.eclipse.console.views.QueryPageViewer$ContentProviderImpl.getElements(Unknown Source)
at org.eclipse.jface.viewers.StructuredViewer.getRawChildren(StructuredViewer.java:848)
at org.eclipse.jface.viewers.TableViewer.getRawChildren(TableViewer.java:1086)
at org.eclipse.jface.viewers.StructuredViewer.getFilteredChildren(StructuredViewer.java:790)
at org.eclipse.jface.viewers.StructuredViewer.getSortedChildren(StructuredViewer.java:905)
at org.eclipse.jface.viewers.TableViewer.internalRefreshAll(TableViewer.java:798)
at org.eclipse.jface.viewers.TableViewer.internalRefresh(TableViewer.java:748)
at org.eclipse.jface.viewers.TableViewer.internalRefresh(TableViewer.java:737)
at org.eclipse.jface.viewers.StructuredViewer$7.run(StructuredViewer.java:1264)
at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1201)
at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:1262)
at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:1221)
at org.eclipse.jface.viewers.TableViewer.inputChanged(TableViewer.java:698)
at org.eclipse.jface.viewers.ContentViewer.setInput(ContentViewer.java:248)
at org.eclipse.jface.viewers.StructuredViewer.setInput(StructuredViewer.java:1417)
at org.hibernate.eclipse.console.views.QueryPageViewer.createTable(Unknown Source)
at org.hibernate.eclipse.console.views.QueryPageViewer.createControl(Unknown Source)
at org.hibernate.eclipse.console.views.QueryPageViewer.<init>(Unknown Source)
at org.hibernate.eclipse.console.views.QueryPageTabView.rebuild(Unknown Source)
at org.hibernate.eclipse.console.views.QueryPageTabView$1.contentsChanged(Unknown Source)
at org.hibernate.eclipse.console.views.QueryPageTabView$1.intervalAdded(Unknown Source)
at javax.swing.AbstractListModel.fireIntervalAdded(AbstractListModel.java:130)
at org.hibernate.console.QueryPageModel.add(Unknown Source)
at org.hibernate.console.KnownConfigurations$1.queryPageCreated(Unknown Source)
at org.hibernate.console.ConsoleConfiguration.fireQueryPageCreated(Unknown Source)
at org.hibernate.console.ConsoleConfiguration.access$5(Unknown Source)
at org.hibernate.console.ConsoleConfiguration$3.execute(Unknown Source)
at org.hibernate.console.execution.DefaultExecutionContext.execute(Unknown Source)
at org.hibernate.console.ConsoleConfiguration.executeHQLQuery(Unknown Source)
at org.hibernate.eclipse.console.actions.ExecuteHQLAction.execute(Unknown Source)
at org.hibernate.eclipse.console.actions.ExecuteHQLAction.run(Unknown Source)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:996)
at org.hibernate.eclipse.console.actions.ExecuteHQLAction.runWithEvent(Unknown Source)
at org.eclipse.ui.actions.RetargetAction.runWithEvent(RetargetAction.java:222)
at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:228)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:538)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:488)
at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:441)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3080)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2713)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1699)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:367)
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:226)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163)
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:585)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334)
at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
at org.eclipse.core.launcher.Main.run(Main.java:973)
at org.eclipse.core.launcher.Main.main(Main.java:948)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 26, 2005 3:34 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
show me the generated hibernate.cfg.xml and one of the hbm.xmls.

yes auto complete is only implemented for the entity names at the moment.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: It works on PostgreSQL
PostPosted: Wed Oct 26, 2005 3:50 pm 
Beginner
Beginner

Joined: Sun Oct 16, 2005 12:37 pm
Posts: 47
Location: Romania, Galati
I don't know how can atach a file to this reply but I think the problem is Mysql database. I ran a simple main application with the HQL early mention and same error I obtained. Then I put all for PostgreSQL and works fine. I didn't do that yet in HQL scratchpad for test.

The hibernate.cfg.xml file is

<?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>
<property name="hibernate.cglib.use_reflection_optimizer">true</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.password">agress04</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3336/merp</property>
<property name="hibernate.connection.username">merp04</property>
<property name="hibernate.default_schema">merp</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<mapping resource="com/agress/merp/model/Personal.hbm.xml" />
<!-- so on -->
</session-factory>
</hibernate-configuration>

Personal.hbm.xml file is

<?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="com.agress.merp.model.Personal" table="personal" schema="merp">
<id name="personalId" type="string">
<column name="personalId" length="9" />
<generator class="assigned" />
</id>
<property name="nume" type="string">
<column name="nume" length="50" not-null="true" />
</property>
<property name="prenume" type="string">
<column name="prenume" length="50" not-null="true" />
</property>
<property name="cnp" type="string">
<column name="CNP" length="13" unique="true" />
</property>
<property name="dataNasterii" type="date">
<column name="data_nasterii" length="10" />
</property>
<property name="adresa" type="string">
<column name="adresa" length="75" />
</property>
<property name="localitate" type="string">
<column name="localitate" length="15" />
</property>
<property name="judet" type="string">
<column name="judet" length="15" />
</property>
<property name="serieActIdentitate" type="string">
<column name="serie_act_identitate" length="8" />
</property>
<property name="eliberatDe" type="string">
<column name="eliberat_de" length="20" />
</property>
<property name="dataEliberarii" type="date">
<column name="data_eliberarii" length="10" />
</property>
<property name="telefonFix" type="string">
<column name="telefon_fix" length="15" />
</property>
<property name="mobil" type="string">
<column name="mobil" length="15" />
</property>
<property name="email" type="string">
<column name="email" length="30" />
</property>
<property name="rezultat" type="integer">
<column name="rezultat" not-null="true" />
</property>
<property name="contorIncercari" type="integer">
<column name="contor_incercari" not-null="true" />
</property>
<property name="flag" type="integer">
<column name="flag" not-null="true" />
</property>
<set name="documenteGenerices" inverse="true">
<key>
<column name="primitorId" length="9" />
</key>
<one-to-many class="com.agress.merp.model.DocumenteGenerice" />
</set>
<set name="documenteGenerices_1" inverse="true">
<key>
<column name="agentId" length="9" />
</key>
<one-to-many class="com.agress.merp.model.DocumenteGenerice" />
</set>
<set name="utilizatoris" inverse="true">
<key>
<column name="PersonalId" length="9" not-null="true" unique="true" />
</key>
<one-to-many class="com.agress.merp.model.Utilizatori" />
</set>
<set name="departamentePersonals" inverse="true">
<key>
<column name="personalId" length="9" />
</key>
<one-to-many class="com.agress.merp.model.DepartamentePersonal" />
</set>
<set name="delegatis" inverse="true">
<key>
<column name="personalid" length="9" />
</key>
<one-to-many class="com.agress.merp.model.Delegati" />
</set>
<set name="contractes" inverse="true">
<key>
<column name="personal_aprobareId" length="9" />
</key>
<one-to-many class="com.agress.merp.model.Contracte" />
</set>
<set name="contractes_1" inverse="true">
<key>
<column name="personal_solicitantId" length="9" not-null="true" />
</key>
<one-to-many class="com.agress.merp.model.Contracte" />
</set>
<set name="soferis" inverse="true">
<key>
<column name="personalId" length="9" not-null="true" />
</key>
<one-to-many class="com.agress.merp.model.Soferi" />
</set>
<set name="coletes" inverse="true">
<key>
<column name="personalid" length="9" />
</key>
<one-to-many class="com.agress.merp.model.Colete" />
</set>
<set name="documenteGenerices_2" inverse="true">
<key>
<column name="personalId" length="9" />
</key>
<one-to-many class="com.agress.merp.model.DocumenteGenerice" />
</set>
<set name="personalLocatiis" inverse="true">
<key>
<column name="personalId" length="9" />
</key>
<one-to-many class="com.agress.merp.model.PersonalLocatii" />
</set>
<set name="gestionaris" inverse="true">
<key>
<column name="personalid" length="9" />
</key>
<one-to-many class="com.agress.merp.model.Gestionari" />
</set>
</class>
</hibernate-mapping>

This is the mapping file and config file that I changed for PostgreSQL and all was OKI, from standalone application, but didn't work for MySQL in same standalone application with right conf for database (obtain from reverse and seemed okie for me).

Thx in advance, ToniC



max wrote:
show me the generated hibernate.cfg.xml and one of the hbm.xmls.

yes auto complete is only implemented for the entity names at the moment.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 26, 2005 4:06 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
merp_ is because of the schema attribte.

merp. should only get there when you have a catalog defined ? do you have that set somewhere ?

try and do it without referring to a schema in the cfg.xml

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Thx a lot for help.
PostPosted: Wed Oct 26, 2005 4:19 pm 
Beginner
Beginner

Joined: Sun Oct 16, 2005 12:37 pm
Posts: 47
Location: Romania, Galati
Yes, mysql has no catalog. Now it works fine. I try hibernate until now only on PostgreSQL.

Thx a lot for help. It was the fastest response with answer for my problem that I ever received. Thx again.

max wrote:
merp_ is because of the schema attribte.

merp. should only get there when you have a catalog defined ? do you have that set somewhere ?

try and do it without referring to a schema in the cfg.xml


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.