-->
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: Hibernate - Oracle Issue - Unable to move - Query Displayed
PostPosted: Thu Apr 27, 2006 10:35 am 
Newbie

Joined: Thu Apr 27, 2006 9:15 am
Posts: 3
Please have a look at the provided code and configuration.
IT seems correct as the SQL is displayed correctly in the logs.

But when its run from Hibernate it says Table or View does not exist.

I tried this directly from JDBC but there it required table name in Double Quotes for e.g. "Customers", I am not sure if Hibernate has a provision for this.

Please suggest if i am missing something or doing something wrong.


Hibernate version:

[27/04/06 15:22:00:766 BST] 52bbac0c Environment I org.hibernate.cfg.Environment Hibernate 3.1.2
[27/04/06 15:22:00:781 BST] 52bbac0c Environment I org.hibernate.cfg.Environment using JDK 1.4 java.sql.Timestamp handling
[27/04/06 15:22:01:047 BST] 52bbac0c Configuration I org.hibernate.cfg.Configuration configuring from resource: /hibernate.cfg.xml
[27/04/06 15:22:01:266 BST] 52bbac0c Configuration I org.hibernate.cfg.Configuration Reading mappings from resource: model/Customer.hbm.xml
[27/04/06 15:22:01:438 BST] 52bbac0c HbmBinder I org.hibernate.cfg.HbmBinder Mapping class: model.Customer -> Customers
[27/04/06 15:22:01:531 BST] 52bbac0c Configuration I org.hibernate.cfg.Configuration Configured SessionFactory: null
[27/04/06 15:22:01:750 BST] 52bbac0c DriverManager I org.hibernate.connection.DriverManagerConnectionProvider Using Hibernate built-in connection pool (not for production use!)
[27/04/06 15:22:01:750 BST] 52bbac0c DriverManager I org.hibernate.connection.DriverManagerConnectionProvider Hibernate connection pool size: 20
[27/04/06 15:22:01:750 BST] 52bbac0c DriverManager I org.hibernate.connection.DriverManagerConnectionProvider autocommit mode: false
[27/04/06 15:22:01:750 BST] 52bbac0c DriverManager I org.hibernate.connection.DriverManagerConnectionProvider using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@XX.XXX.XX.XX:1584:FITSD1
[27/04/06 15:22:01:750 BST] 52bbac0c DriverManager I org.hibernate.connection.DriverManagerConnectionProvider connection properties: {user=fitsmgr, password=****}
[27/04/06 15:22:05:312 BST] 52bbac0c SettingsFacto I org.hibernate.cfg.SettingsFactory RDBMS: Oracle, version: Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.6.0 - Production
[27/04/06 15:22:05:328 BST] 52bbac0c SettingsFacto I org.hibernate.cfg.SettingsFactory JDBC driver: Oracle JDBC driver, version: 9.2.0.5.0
[27/04/06 15:22:05:391 BST] 52bbac0c Dialect I org.hibernate.dialect.Dialect Using dialect: org.hibernate.dialect.OracleDialect
[27/04/06 15:22:06:984 BST] 52bbac0c WebGroup I SRVE0180I: [TMTApplication] [/.TMTApplication] [Servlet.LOG]: /TMTApplicationView.jsp: init


Mapping documents:

<hibernate-configuration>

<session-factory>

<!-- Connection Properties -->
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@10.196.34.30:1584:FITSD1</property>
<property name="hibernate.connection.username">fitsmgr</property>
<property name="hibernate.connection.password">fitsdev</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<property name="dialect">org.hibernate.dialect.OracleDialect</property>

<property name="hibernate.format_sql">true</property>
<property name="hibernate.default_schema">FITSMGR</property>

<!-- Show SQL logging -->
<property name="hibernate.show_sql">true</property>

<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

<!-- Mapping files -->
<mapping resource="model/Customer.hbm.xml"/>
</session-factory>
</hibernate-configuration>

Simple Customer Entity Mapping Class
<hibernate-mapping schema="FITSMGR">
<class name="model.Customer" table="Customers">
<id name="customerCode" column="CustomerCode">
<generator class="assigned"/>
</id>
<property name="customerName" column="CustomerName" type="string" />
<property name="sla" column="SLA" />
</class>
</hibernate-mapping>


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

Full stack trace of any exception that occurs:
Caused by: 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:2148)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1129)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at com.cw.portal.tmt.business.CustomerDAOHibernateImpl.findAllCustomers(CustomerDAOHibernateImpl.java:37)
at com.cw.portal.tmt.business.FindAllCustomersCommand.doBusinessLogic(FindAllCustomersCommand.java:20)
at com.cw.portal.tmt.business.BusinessCommand.execute(BusinessCommand.java:70)
at com.cw.portal.tmt.web.CustomerManager.getCustomerList(CustomerManager.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java(Compiled Code))
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java(Compiled Code))
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled Code))
at java.lang.reflect.Method.invoke(Method.java(Compiled Code))
at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)
... 67 more
Caused by: java.sql.SQLException: ORA-00942: table or view does not exist

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:582)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1986)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:880)
at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2516)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2850)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:609)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:537)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
... 84 more

[27/04/06 15:27:20:750 BST] 41eb2c0c SystemOut O Hibernate:
[b] select
customer0_.CustomerCode as Customer1_0_,
customer0_.CustomerName as Customer2_0_,
customer0_.SLA as SLA0_
from
FITSMGR.Customers customer0_
[27/04/06 15:27:20:781 BST] 41eb2c0c JDBCException W org.hibernate.util.JDBCExceptionReporter SQL Error: 942, SQLState: 42000
[27/04/06 15:27:20:797 BST] 41eb2c0c JDBCException E org.hibernate.util.JDBCExceptionReporter ORA-00942: table or view does not exist

[27/04/06 15:27:20:797 BST] 41eb2c0c BusinessComma E com.cw.portal.tmt.business.BusinessCommand Problem executing business command
[27/04/06 15:27:20:812 BST] 41eb2c0c BusinessComma E com.cw.portal.tmt.business.BusinessCommand TRAS0014I: The following exception was logged 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:2148)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
[/b]

Name and version of the database you are using:

RDBMS: Oracle, version: Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit.


The generated SQL (show_sql=true):
select
customer0_.CustomerCode as Customer1_0_,
customer0_.CustomerName as Customer2_0_,
customer0_.SLA as SLA0_
from
FITSMGR.Customers customer0_


Debug level Hibernate log excerpt:
Caused by: 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:2148)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1129)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at com.cw.portal.tmt.business.CustomerDAOHibernateImpl.findAllCustomers(CustomerDAOHibernateImpl.java:37)
at com.cw.portal.tmt.business.FindAllCustomersCommand.doBusinessLogic(FindAllCustomersCommand.java:20)
at com.cw.portal.tmt.business.BusinessCommand.execute(BusinessCommand.java:70)
at com.cw.portal.tmt.web.CustomerManager.getCustomerList(CustomerManager.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java(Compiled Code))
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java(Compiled Code))
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled Code))
at java.lang.reflect.Method.invoke(Method.java(Compiled Code))
at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)
... 67 more



Please have a look at the above provided code and configuration.
IT seems correct as the SQL is displayed correctly in the logs.

But when its run from Hibernate it says Table or View does not exist.

I tried this directly from JDBC but there it required table name in Double Quotes for e.g. "Customers", I am not sure if Hibernate has a provision for this.

Please suggest if i am missing something or doing something wrong.

_________________
Thanks & Regards
-Ashish


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 27, 2006 11:04 am 
Expert
Expert

Joined: Tue Apr 25, 2006 12:04 pm
Posts: 260
Check if Connection object is obtained from Session.


Top
 Profile  
 
 Post subject: Yes, Connection is fine
PostPosted: Thu Apr 27, 2006 11:19 am 
Newbie

Joined: Thu Apr 27, 2006 9:15 am
Posts: 3
bkmr_77 wrote:
Check if Connection object is obtained from Session.


Yes, Connection is getting obtained as shown in the logs of reading hibernate.cfg.xml.

Thanks
-Regards

_________________
Thanks & Regards
-Ashish


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 27, 2006 11:41 am 
Expert
Expert

Joined: Tue Apr 25, 2006 12:04 pm
Posts: 260
Sorry for not being more detailed.

I meant try to verify the Connection object from within your code. For example, within the java file com.cw.portal.tmt.business.CustomerDAOHibernateImpl and findAllCustomers() method you would be creating Hibernate Session object. Check to see if the session.connection() is returning an object and try to execute the regular JDBC statments. And verify if everything is working normally with this approach.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 28, 2006 6:10 am 
Newbie

Joined: Thu Apr 27, 2006 9:15 am
Posts: 3
bkmr_77 wrote:
Sorry for not being more detailed.

I meant try to verify the Connection object from within your code. For example, within the java file com.cw.portal.tmt.business.CustomerDAOHibernateImpl and findAllCustomers() method you would be creating Hibernate Session object. Check to see if the session.connection() is returning an object and try to execute the regular JDBC statments. And verify if everything is working normally with this approach.


I tried with that option as well but it seems the Database table & column name are in double quotes for e.g.
TableName = "Customers"
ColumnName = "CustomerName"

From JDBC if SQL is
select * from "Customers" it WORKS
But if SQL is
select * from Customers it dosen't WORK
Check "Customers" table in double quote...

Can someone suggest if we can configure Hibernate to take Tablename and column names with in double quotes.

Your help is highly appreciated....

_________________
Thanks & Regards
-Ashish


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.