-->
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.  [ 4 posts ] 
Author Message
 Post subject: Problem with selecting from MySql Table in Hibernate.
PostPosted: Wed Dec 01, 2004 2:27 am 
Newbie

Joined: Mon Nov 29, 2004 8:15 pm
Posts: 6
Hibernate version:
2.1.7c


Mapping documents:
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

<class name="com.iflex.hibernate.Event" table="EVENTS">
<id name="id" column="uid" type="long">
<generator class="increment"/>
</id>
<property name="title" column="event_title" type="string"/>
</class>

</hibernate-mapping>


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

Transaction tx = null;
tx = sess.beginTransaction();
session.save(ev);
tx.commit();


Full stack trace of any exception that occurs:
net.sf.hibernate.exception.SQLGrammarException: Could not save object
at net.sf.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:69)
at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:30)
at net.sf.hibernate.impl.SessionImpl.convert(SessionImpl.java:4110)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:792)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:747)
at com.iflex.hibernate.EventManager.DoUpdate(EventManager.java:47)
at com.iflex.hibernate.EventManager.main(EventManager.java:77)
Caused by: java.sql.SQLException: Table not found: EVENTS in statement [select max(uid) from "EVENTS"]
at org.hsqldb.Trace.getError(Unknown Source)
at org.hsqldb.jdbcResultSet.<init>(Unknown Source)
at org.hsqldb.jdbcConnection.executeStandalone(Unknown Source)
at org.hsqldb.jdbcConnection.execute(Unknown Source)
at org.hsqldb.jdbcStatement.fetchResult(Unknown Source)
at org.hsqldb.jdbcStatement.executeQuery(Unknown Source)
at org.hsqldb.jdbcPreparedStatement.executeQuery(Unknown Source)
at net.sf.hibernate.id.IncrementGenerator.getNext(IncrementGenerator.java:68)
at net.sf.hibernate.id.IncrementGenerator.generate(IncrementGenerator.java:42)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:774)
... 3 more



Name and version of the database you are using:
MySql 4.1.7-nt


The generated SQL (show_sql=true):



Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 01, 2004 9:37 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Well looks like the table you have mapped does not exist. Check your db and db configuration.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 05, 2004 11:48 pm 
Newbie

Joined: Fri Oct 31, 2003 3:14 pm
Posts: 12
Location: New York, NY
Just an FYI, it appears IncrementGenerator was broken in 2.1.7 as it always quotes the table name. With Oracle, Postgresql, andMySQL, quoting a table name forces case-sensitivity. If your table is named "orders", then MySQL won't find "ORDERS" (that's the name in the SQL printed out).

I've noticed this change has already been rolled back in CVS...just waiting on the next Hibernate release to get this fix.

The change was an attempt to fix HB-1315 but I think it backfired. I'm still trying to figure out exactly what the problem was. The only I could see when debugging it was that if you specify a quoted identifier for a table name in your hbm file, the IncrementGenerator doesn't seem to pick it up. That might be the actual bug there.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 17, 2004 5:44 pm 
Newbie

Joined: Wed Mar 17, 2004 7:44 pm
Posts: 7
Location: Chicago Area, IL, US
Thank you pburleson. I noticed that using increment for primary keys with HSQLDB was blowing up in 2.1.7c. I found that the quoted table name in the generated SQL was responsible. It is good to know that Gavin, Christian et. al. are aware of the problem and are working to repair it in 2.1.7d.


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