-->
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: Hibernate getting table names wrong...
PostPosted: Mon Feb 07, 2005 12:58 pm 
Beginner
Beginner

Joined: Tue Feb 01, 2005 8:38 am
Posts: 38
Hi,

I'm experiencing a problem whereby Hibernate prepends two dots (fullstop, periods, whatever you want to call it) to the start of my table name before executing the query. The resulting effect being that I get a "java.sql.SQLException: ORA-00903: invalid table name" exception.

Two things to note:
1. The code was generated by the eclipse plugin tool for reverse engineering from a database.

2. When I run against a MYSQL database with the same schema it prepends to underscores to the table name instead of two dots!

Hibernate version: 3.0

Mapping documents:

Code:
<?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="DeviceCategory" table="DEVICE_CATEGORY" catalog="">
    <id name="DeviceCategoryId" type="java.lang.Integer">
      <column name="DEVICE_CATEGORY_ID" length="11" not-null="true" sql-type="int" />
      <generator class="assigned" />
    </id>
    <property name="NetworkFrequency" type="java.lang.String">
      <column name="NETWORK_FREQUENCY" length="100" not-null="true" sql-type="varchar" />
    </property>
    <property name="Description" type="java.lang.String">
      <column name="DESCRIPTION" not-null="true" sql-type="varchar" />
    </property>
    <set name="SetOfRoamingPartner">
      <key>
        <column name="MINIMUM_DEVICE_REQUIREMENT_ID" length="11" not-null="false" unique="true" />
      </key>
      <one-to-many class="RoamingPartner" />
    </set>
  </class>
</hibernate-mapping>

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

Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
List result = session.createQuery("from ROAMING_CHARGES.DEVICE_CATEGORY as d").list();
tx.commit();
session.close();


Full stack trace of any exception that occurs:

java.sql.SQLException: ORA-00903: invalid table name

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:822)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:1446)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1371)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:2883)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:155)
at org.hibernate.impl.ActionQueue.executeActions(ActionQueue.java:227)
at org.hibernate.impl.ActionQueue.executeActions(ActionQueue.java:137)
at org.hibernate.event.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:265)
at org.hibernate.event.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:24)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:815)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:75)
at HibernateTest.main(HibernateTest.java:55)
WARN - SQL Error: 903, SQLState: 42000
ERROR - ORA-00903: invalid table name

ERROR - Could not synchronize database state with session
org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:70)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:162)
at org.hibernate.impl.ActionQueue.executeActions(ActionQueue.java:227)
at org.hibernate.impl.ActionQueue.executeActions(ActionQueue.java:137)
at org.hibernate.event.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:265)
at org.hibernate.event.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:24)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:815)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:75)
at HibernateTest.main(HibernateTest.java:55)
Caused by: java.sql.SQLException: ORA-00903: invalid table name

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:822)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:1446)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1371)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:2883)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:155)
... 7 more
org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:70)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:162)
at org.hibernate.impl.ActionQueue.executeActions(ActionQueue.java:227)
at org.hibernate.impl.ActionQueue.executeActions(ActionQueue.java:137)
at org.hibernate.event.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:265)
at org.hibernate.event.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:24)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:815)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:75)
at HibernateTest.main(HibernateTest.java:55)
Caused by: java.sql.SQLException: ORA-00903: invalid table name

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:822)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:1446)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1371)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:2883)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:155)
... 7 more



Name and version of the database you are using: Oracle 8i

The generated SQL (show_sql=true):

insert into ..DEVICE_CATEGORY (NETWORK_FREQUENCY, DESCRIPTION, DEVICE_CATEGORY_ID) values (?, ?, ?)


Debug level Hibernate log excerpt:

DEBUG - opened session
DEBUG - begin
DEBUG - opening JDBC connection
DEBUG - total checked-out connections: 0
DEBUG - using pooled JDBC connection, pool size: 0
DEBUG - current autocommit status: false
DEBUG - saving transient instance
DEBUG - saving [DeviceCategory#1]
DEBUG - commit
DEBUG - flushing session
DEBUG - Flushing entities and processing referenced collections
DEBUG - Processing unreferenced collections
DEBUG - Scheduling collection removes/(re)creates/updates
DEBUG - Flushed: 1 insertions, 0 updates, 0 deletions to 1 objects
DEBUG - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
DEBUG - listing entities:
DEBUG - DeviceCategory{NetworkFrequency=1900, Description=TestCat, SetOfRoamingPartner=null, DeviceCategoryId=1}
DEBUG - executing flush
DEBUG - Inserting entity: [DeviceCategory#1]
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - insert into ..DEVICE_CATEGORY (NETWORK_FREQUENCY, DESCRIPTION, DEVICE_CATEGORY_ID) values (?, ?, ?)
DEBUG - preparing statement
DEBUG - Dehydrating entity: [DeviceCategory#1]
DEBUG - binding '1900' to parameter: 1
DEBUG - binding 'TestCat' to parameter: 2
DEBUG - binding '1' to parameter: 3
DEBUG - Adding to batch
DEBUG - Executing batch size: 1
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - closing statement
DEBUG - Could not execute JDBC batch update [insert into ..DEVICE_CATEGORY (NETWORK_FREQUENCY, DESCRIPTION, DEVICE_CATEGORY_ID) values (?, ?, ?)]
java.sql.SQLException: ORA-00903: invalid table name

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:822)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:1446)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1371)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:2883)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:155)
at org.hibernate.impl.ActionQueue.executeActions(ActionQueue.java:227)
at org.hibernate.impl.ActionQueue.executeActions(ActionQueue.java:137)
at org.hibernate.event.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:265)
at org.hibernate.event.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:24)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:815)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:75)
at HibernateTest.main(HibernateTest.java:55)
WARN - SQL Error: 903, SQLState: 42000
ERROR - ORA-00903: invalid table name

ERROR - Could not synchronize database state with session
org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:70)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:162)
at org.hibernate.impl.ActionQueue.executeActions(ActionQueue.java:227)
at org.hibernate.impl.ActionQueue.executeActions(ActionQueue.java:137)
at org.hibernate.event.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:265)
at org.hibernate.event.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:24)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:815)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:75)
at HibernateTest.main(HibernateTest.java:55)
Caused by: java.sql.SQLException: ORA-00903: invalid table name

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:822)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:1446)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1371)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:2883)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:155)
... 7 more
org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:70)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:162)
at org.hibernate.impl.ActionQueue.executeActions(ActionQueue.java:227)
at org.hibernate.impl.ActionQueue.executeActions(ActionQueue.java:137)
at org.hibernate.event.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:265)
at org.hibernate.event.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:24)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:815)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:75)
at HibernateTest.main(HibernateTest.java:55)
Caused by: java.sql.SQLException: ORA-00903: invalid table name

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:822)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:1446)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1371)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:2883)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:155)
... 7 more


Any help on this issue would be much appreciated as it's totally preventing me from using Hibernate.

Cheers,

John :)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 07, 2005 1:07 pm 
Beginner
Beginner

Joined: Tue Feb 01, 2005 8:38 am
Posts: 38
Please note. I have tried the following HQL statements and get the same result...

List result = session.createQuery("from ROAMING_CHARGES.DEVICE_CATEGORY as d").list();

List result = session.createQuery("from DEVICE_CATEGORY as d").list();

List result = session.createQuery("from DEVICE_CATEGORY").list();

Cheers :)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 07, 2005 1:14 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
This might be a bug. Either tools should not create an empty catalog attribute, or Hibernate should ignore an empty catalog attribute. I'd say file a JIRA entry against Tools.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 07, 2005 1:27 pm 
Beginner
Beginner

Joined: Tue Feb 01, 2005 8:38 am
Posts: 38
Okay... I removed the catalog="" tag from my config file and it runs okay now.


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.