Hibernate 3.1 giving problem with oracle 10g

My code was working with MS SQL server but after i changed my configurations to use my code with oracle 10g, afore mentioned exceptions are coming. Tables are not getting created automatically.

Any ideas if I am using a wrong driver or dialect.

An excerpt from my hibernate.cfg.xml

<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>

<property name="hibernate.connection.url">jdbc:oracle:thin:@192.168.0.99:1521:Oraware</property>

<property name="hibernate.connection.username">fahad</property>

<property name="hibernate.connection.password">prodoc</property>

<property name="hibernate.connection.pool_size">10</property>

<property name="show_sql">true</property>

<property name="hibernate.current_session_context_class">thread</property>

<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>

<property name="hibernate.hbm2ddl.auto">update</property>

Exception Stack Trace :

org.hibernate.exception.SQLGrammarException: could not execute query

at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:65)

at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)

at org.hibernate.loader.Loader.doList(Loader.java:2150)

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:298)

at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1020)

at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)

at workflowtracker.Tracker.workflowCompleted(Tracker.java:129)

at workflowtracker.Tracker.startNewWorkflow(Tracker.java:213)

at workflowtracker.WorkflowTracker.eventOccured(WorkflowTracker.java:78)

at watchdog.manager.WatchDog.eventOccured(WatchDog.java:63)

at watchdog.monitors.Monitor.eventOccured(Monitor.java:138)

at watchdog.monitors.FileSystemMonitor.monitorAnyFileCreation(FileSystemMonitor.java:133)

at watchdog.monitors.FileSystemMonitor.monitor(FileSystemMonitor.java:88)

at watchdog.monitors.FileSystemMonitor.run(FileSystemMonitor.java:72)

at java.lang.Thread.run(Thread.java:595)

Caused by: java.sql.SQLException: ORA-00933: SQL command not properly ended

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)

at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)

at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)

at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)

at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)

at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:799)

at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1037)

at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:839)

at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1132)

at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3316)

at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3361)

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)

... 15 more

Hibernate: select welllog0_.wellLogID as wellLogID2_, welllog0_.created as created2_, welllog0_.wellID as wellID2_ from WellLog.dbo.WellLog welllog0_ where welllog0_.wellID='g4yr'

org.hibernate.exception.SQLGrammarException: could not execute query

at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:65)

at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)

at org.hibernate.loader.Loader.doList(Loader.java:2150)

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:298)

at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1020)

at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)

at workflowtracker.Tracker.startNewWorkflow(Tracker.java:221)

at workflowtracker.WorkflowTracker.eventOccured(WorkflowTracker.java:78)

at watchdog.manager.WatchDog.eventOccured(WatchDog.java:63)

at watchdog.monitors.Monitor.eventOccured(Monitor.java:138)

at watchdog.monitors.FileSystemMonitor.monitorAnyFileCreation(FileSystemMonitor.java:133)

at watchdog.monitors.FileSystemMonitor.monitor(FileSystemMonitor.java:88)

at watchdog.monitors.FileSystemMonitor.run(FileSystemMonitor.java:72)

at java.lang.Thread.run(Thread.java:595)

Caused by: java.sql.SQLException: ORA-00933: SQL command not properly ended

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)

at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)

at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)

at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)

at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)

at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:799)

at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1037)

at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:839)

at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1132)

at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3316)

at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3361)

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)

... 14 more

[6880 byte] By [fahada] at [2007-10-3 8:28:06]
# 1
Try using asorg.hibernate.dialect.OracleDialect
ashok_lagia at 2007-7-15 3:34:47 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
Caused by: java.sql.SQLException: ORA-00933: SQL command not properly endedAn SQL statement has an error.
dvohra09a at 2007-7-15 3:34:47 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
I saw the same probelm. I tried both OracleDialect and OracleDialect but neither of them works. I also tried using Hibernate 3.2 but it doesn't work either.Have you found out how to solve this problem?Thanks a lot.
sunca at 2007-7-15 3:34:47 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4
select welllog0_.wellLogID as wellLogID2_, welllog0_.created as created2_, welllog0_.wellID as wellID2_ from WellLog.dbo.WellLog welllog0_ where welllog0_.wellID='g4yr'is WellLog.dbo.WellLog as the table ok?
javosoa at 2007-7-15 3:34:47 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5
this is off-topic, but i've rarely seen/heard any good experiences with using either hibernate or oracle. using them together just spells trouble in my mind
MickeyOnJavaa at 2007-7-15 3:34:47 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 6

> this is off-topic, but i've rarely seen/heard any

> good experiences with using either hibernate or

> oracle. using them together just spells trouble in my

> mind

I've had fine success with Oracle, Hibernate, and the two together.

You need to get out more.

%

duffymoa at 2007-7-15 3:34:47 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 7
I found out that I can not use <generator class="identity"/> when talking with oracle. I have to use <generator class="sequence"/> instead.Is this ture or I miss any steps?
sunca at 2007-7-15 3:34:47 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 8

> I found out that I can not use <generator

> class="identity"/> when talking with oracle. I have

> to use <generator class="sequence"/> instead.

Right, because Oracle uses sequences. There is no auto increment or identity type in Oracle.

> Is this ture or I miss any steps?

It's true, but it sounds like you missed something important about Oracle.

%

duffymoa at 2007-7-15 3:34:47 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 9
identity is found in MS Access and SQL Server and MySQL.Oracle and PostgreSQL use sequences.It's not a problem with Hibernate, it's a matter of knowing something about your underlying RDBMS.%
duffymoa at 2007-7-15 3:34:47 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 10

> this is off-topic, but i've rarely seen/heard any

> good experiences with using either hibernate or

> oracle. using them together just spells trouble in my

> mind

I have rarely heard of troubles with either. And troubles with both are almost always traced to the users rather than the product.

jschella at 2007-7-15 3:34:47 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 11
Hibernate with Oracle database. http://www.ftponline.com/channels/java/2006_01/dvohra2/
dvohra09a at 2007-7-15 3:34:47 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 12
I'm late to the party here, but using this:<generator class="native"/>Will generally give you the best key type for the database you're using as long as you're using the right dialect (and expect more significant problems if you're not anyway!)
dcmintera at 2007-7-15 3:34:47 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 13

I am facing the same problem as in this message. I have written a simple custom query in .hbm.xml file: select distinct ref.title from Training_ref ref where division='WHHM'

And I am executing this query like this:

Query q = sessionFactory.getCurrentSession().getNamedQuery(

query);

List results = q.list();

This works fine in HSQL DB. But throws Caused by: java.sql.SQLException: ORA-00933: SQL command not properly ended in Oracle10g.

I have tried with both OracleDialect and Oracle9Dialect.

Any help is appreciated.

-yogen

yyogena at 2007-7-15 3:34:47 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 14

I use Oracle 10 with Hibernate 3.2 and I've not had this problem, so I suspect that there's some other issue. Could you try amending your query to the following and seeing if that fixes the issue?

select distinct ref.title from Training_ref ref where ref.division='WHHM'

Assuming it doesn't (and this is purely a guess, so it may well not) could you paste in the SQL that your query is generating? You can turn on generated SQL output with the hibernate.show_sql property.

dcmintera at 2007-7-15 3:34:47 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...