-->
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: new to hibernate !!!
PostPosted: Thu Jun 22, 2006 8:44 am 
Newbie

Joined: Thu Jun 22, 2006 7:34 am
Posts: 3
Hi

I took the example found here : http://www.gloegl.de/15.html ( hibernate and hsqldb ) and converted it to work for Oracle 9i . It's a simple application. But it's just not working !

Exception ( pretty long :-p )
----------------------------------
....
....
INFO - schema update complete
INFO - cleaning up connection pool: jdbc:oracle:thin:@10.80.122.55:1521:MyDB
INFO - Checking 0 named queries
Hibernate: select SEQ_INCREMENT.nextval from dual
Hibernate: insert into EVENTS (date, eventtitle, uid) values (?, ?, ?)
WARN - SQL Error: 928, SQLState: 42000
ERROR - ORA-00928: missing SELECT keyword

WARN - SQL Error: 928, SQLState: 42000
ERROR - ORA-00928: missing SELECT keyword

ERROR - Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92)
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:80)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:161)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:136)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:669)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:293)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
at de.gloegl.road2hibernate.EventManager.storeEvent(EventManager.java:80)
at de.gloegl.road2hibernate.EventManager.main(EventManager.java:18)
Caused by: java.sql.BatchUpdateException: ORA-00928: missing SELECT keyword

at oracle.jdbc.dbaccess.DBError.throwBatchUpdateException(DBError.java:459)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:3907)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:154)
... 9 more
java.lang.RuntimeException: org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
at de.gloegl.road2hibernate.EventManager.storeEvent(EventManager.java:86)
at de.gloegl.road2hibernate.EventManager.main(EventManager.java:18)
Caused by: org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92)
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:80)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:161)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:136)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:669)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:293)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
at de.gloegl.road2hibernate.EventManager.storeEvent(EventManager.java:80)
... 1 more
Caused by: java.sql.BatchUpdateException: ORA-00928: missing SELECT keyword

at oracle.jdbc.dbaccess.DBError.throwBatchUpdateException(DBError.java:459)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:3907)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:154)
... 9 more
Exception in thread "main"

Hibernate config file
-----------------------
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@<ip here >:1521:MyDB</property>
<property name="hibernate.connection.username">hibernate</property>
<property name="hibernate.connection.password">hibernate</property>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="show_sql">true</property>
<property name="transaction.factory_class">
org.hibernate.transaction.JDBCTransactionFactory
</property>
<property name="hibernate.cache.provider_class">
org.hibernate.cache.HashtableCacheProvider
</property>
<property name="hibernate.connection.pool_size">3</property>
<property name="hibernate.hbm2ddl.auto">update</property>

<mapping resource="de/gloegl/road2hibernate/Event.hbm.xml"/>
<mapping resource="de/gloegl/road2hibernate/User.hbm.xml"/>

</session-factory>

</hibernate-configuration>

Please note that the connection is absolutely fine. It's the batch update when I try and add a record via a bean called Event.

What can be wrong ??

Help !



Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

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

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 22, 2006 8:56 am 
Regular
Regular

Joined: Wed Jan 11, 2006 12:49 pm
Posts: 64
Location: Campinas, Brazil
Actually this is a problem with the Hibernate dialect. DATE is reserved in oracle, so it should be enclosed in double quotes when referring a column or table name. Try renaming the column to some other name.

_________________
Henrique Sousa
Don't forget to rate useful responses


Top
 Profile  
 
 Post subject: renames the Date column, still does not work !
PostPosted: Fri Jun 23, 2006 7:49 am 
Newbie

Joined: Thu Jun 22, 2006 7:34 am
Posts: 3
I've really simplified my first hibernate - oracle application. Its just has to do an insert into a table called EVENT. Here's the exception :

INFO - Statistics: disabled
INFO - Deleted entity synthetic identifier rollback: disabled
INFO - Default entity-mode: pojo
INFO - building session factory
WARN - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/D:/Mylib/ehcache-1.1.jar!/ehcache-failsafe.xml
INFO - Not binding factory to JNDI, no JNDI name configured
INFO - Using dialect: org.hibernate.dialect.Oracle9Dialect
INFO - Using Hibernate built-in connection pool (not for production use!)
INFO - Hibernate connection pool size: 3
INFO - autocommit mode: false
INFO - using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@10.80.122.55:1521:MyDB
INFO - connection properties: {user=hibernate, password=****}
INFO - Running hbm2ddl schema update
INFO - fetching database metadata
INFO - updating schema
INFO - processing extends queue
INFO - processing collection mappings
INFO - processing association property references
INFO - processing foreign key constraints
INFO - table found: HIBERNATE.EVENT
INFO - columns: [title, uid, date_d]
INFO - foreign keys: []
INFO - indexes: [sys_c002658]
INFO - schema update complete
INFO - cleaning up connection pool: jdbc:oracle:thin:@10.80.122.55:1521:MyDB
INFO - Checking 0 named queries
Hibernate: select SEQ_INCREMENT.nextval from dual
--- saved --- : 28
Hibernate: insert into EVENT (DATE_D, TITLE, uid) values (?, ?, ?)
WARN - SQL Error: 1747, SQLState: 42000
ERROR - ORA-01747: invalid user.table.column, table.column, or column specification

WARN - SQL Error: 1747, SQLState: 42000
ERROR - ORA-01747: invalid user.table.column, table.column, or column specification

ERROR - Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92)
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:80)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:161)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:136)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:669)
at com.neverness.dao.EventManager.storeEvent(EventManager.java:34)
at com.neverness.dao.EventManager.main(EventManager.java:19)
Caused by: java.sql.BatchUpdateException: ORA-01747: invalid user.table.column, table.column, or column specification

at oracle.jdbc.dbaccess.DBError.throwBatchUpdateException(DBError.java:459)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:3907)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:154)
... 7 more
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92)
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:80)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:161)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:136)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:669)
at com.neverness.dao.EventManager.storeEvent(EventManager.java:34)
at com.neverness.dao.EventManager.main(EventManager.java:19)
Caused by: java.sql.BatchUpdateException: ORA-01747: invalid user.table.column, table.column, or column specification

at oracle.jdbc.dbaccess.DBError.throwBatchUpdateException(DBError.java:459)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:3907)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:154)
... 7 more
Hibernate Exception :org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
Saved with id 28

The method will saves
--------------------------
private Event storeEvent(String title, Date theDate) {
Event bean = new Event();
bean.setTitle(title);
bean.setDate(theDate);
Session session = HibernateUtil.currentSession();
Transaction transaction = session.beginTransaction();
try {
session.save(bean);
System.out.println("--- saved --- : " + bean.toString());
session.flush();
transaction.commit();
System.out.println("--- committed ---");
} catch (HibernateException e) {
e.printStackTrace();
System.out.println("Hibernate Exception :" + e);
transaction.rollback();
} finally {
transaction = null;
HibernateUtil.closeSession();
}
return bean ;
}

This exception is actually thrown on the call transaction.commit(); . Why is hibernate giving ORA-01747 .

I've already provided the schema name / pwd with which it should connect. It does the insert and returns the inserted bean ( the id is printed ) but it fails during commit !!!!!

Please help !


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 23, 2006 8:17 am 
Regular
Regular

Joined: Wed Jan 11, 2006 12:49 pm
Posts: 64
Location: Campinas, Brazil
Talk about bad luck... Oracle also does not like the column name "uid". I guess you will have to change this column's name too.

Hibernate folks, how about creating a list of words one cannot use for column names without double quotes in OracleDialect?

_________________
Henrique Sousa
Don't forget to rate useful responses


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 26, 2006 6:06 am 
Newbie

Joined: Thu Jun 22, 2006 7:34 am
Posts: 3
Thanks a lot mate. With all the metadata definition Hibernate requires, ( with the DB dialect specification, etc ), one would think it would be wise for Hibernate to add double quotes for reserved words also.

Well, that's what Oracle Enterprise Manager does.....

Thanks again...it's working now.


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.