-->
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.  [ 6 posts ] 
Author Message
 Post subject: Hibernate Console - Exception executing HQL
PostPosted: Mon Sep 05, 2005 11:04 pm 
Newbie

Joined: Mon Sep 05, 2005 10:55 pm
Posts: 3
I get the following exception when trying to execute HQL from within the Hibernate Console.

java.sql.SQLException: Table 'test.public_product' doesn't exist

using the HQL "from Product p"


From within the Hibernate Console I am able to create my Session Factory and browse the loaded mapped objects fine. In addition, I can browse the DB schema from within the configuration pane.

Also, I believe the mapping files are correct, because I am able to successfully run JUnit tests which make use of my business objects and mapping files. This exception appears only when trying to execute HQL from within the console.

Why is the generated SQL trying to query the table "public_product" instead of table "product"? Why is the "public_" prefix added?

I have searched the forums for an answer, I apologize if I have missed it.

Thanks in advance for any help you can provide!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 06, 2005 1:13 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
which database ?

and show your mapping if you assume they are correct ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 06, 2005 9:07 am 
Newbie

Joined: Mon Sep 05, 2005 10:55 pm
Posts: 3
My mapping file is found below. I am using MySQL 3.23, an older version but should still be fine.


<?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>
<class name="com.yokel.db.Product" table="product">
<id name="id" type="long" unsaved-value="null" column="product_id">
<generator class="identity"/>
</id>

<property name="model" column="model" length="50" />
<property name="desc" column="description" length="255" />
<property name="url" column="prod_url" length="255" />
<property name="status" column="prod_status" length="1" />

<many-to-one class="com.test.db.Category" name="category" column="category_id" insert="true" update="false" not-null="false" />
<many-to-one class="com.test.db.Manufacturer" name="manufacturer" column="mfg_id" insert="true" update="false" not-null="false" />

</class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 06, 2005 9:09 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
have you something set for schema/catalog in your cfg.xml ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 06, 2005 9:21 am 
Newbie

Joined: Mon Sep 05, 2005 10:55 pm
Posts: 3
Max,
I indeed did have something set in my hibernate.cfg.xml file. I removed the following line and all worked well.

<property name="hibernate.default_schema">public</property>


I guess I copied this from another example. I still do not understand why this presents a problem for HQL but not for normal interactions with the DAOs.

Regardless, thanks for helping me track this down!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 06, 2005 9:31 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
it should fail also - with default_schema set you tell hibernate to set the schema for all tables that does not have the schema specified.

_________________
Max
Don't forget to rate


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