-->
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.  [ 6 posts ] 
Author Message
 Post subject: Problem executing query
PostPosted: Thu Jun 14, 2007 8:39 am 
Newbie

Joined: Tue May 08, 2007 3:34 pm
Posts: 19
I am getting the error message below.
Here is the hbm.xm settings:
<hibernate-mapping>
<class name="rapidReview.core.hibernate.PrJournalRoleInfo" table="PR_JOURNAL_ROLE_INFO" schema="AACR20_DBA">
<composite-id name="id" class="rapidReview.core.hibernate.PrJournalRoleInfoId">
<key-property name="prPersonId" type="java.lang.Long">
<column name="PR_PERSON_ID" precision="10" scale="0" />
</key-property>
<key-property name="slNo" type="java.lang.Long">
<column name="SL_NO" precision="10" scale="0" />
</key-property>
</composite-id>
<property name="journalCode" type="java.lang.String">
<column name="JOURNAL_CODE" length="10" not-null="true" />
</property>
<property name="sectionCode" type="java.lang.String">
<column name="SECTION_CODE" length="10" />
</property>
<property name="roleId" type="java.lang.Long">
<column name="ROLE_ID" precision="10" scale="0" not-null="true" />
</property>

Here is the failing code:
hql = "select pr.id from PrJournalRoleInfo pr where pr.id=:personId";
qry = sess.createQuery(hql);
qry.setLong("personId", personId.longValue());

List listMsRoleInfo = qry.list();

Any ideas would be grateful?


13 Jun 2007 18:34:37 [0_623=WebEcommerceSetup] DEBUG -could not execute query [select prjournalr0_.PR_PERSON_ID as col_0_0_, prjournalr0_.SL_NO as col_0_1_ from AACR20_DBA.PR_JOURNAL_ROLE_INFO prjournalr0_ where (prjournalr0_.PR_PERSON_ID, prjournalr0_.SL_NO)=?]
java.sql.SQLException: ORA-00920: invalid relational operator

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:573)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:830)
at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2391)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2672)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:527)
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)
Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html


Top
 Profile  
 
 Post subject: Rewrite query
PostPosted: Thu Jun 14, 2007 9:23 am 
Beginner
Beginner

Joined: Thu Jan 13, 2005 10:50 am
Posts: 30
Location: Minneapolis, MN
Hi,

Your original query
Code:
hql = "select pr.id from PrJournalRoleInfo pr where pr.id=:personId";


I am not very familiar with HQL but I think you should rewrite the query as

Code:
hql = "from PrJournalRoleInfo pr where pr.id=:personId";



**Please rate if the solution was useful **

_________________
** Rate me if the solution was useful **

Regards,
Paras Jain


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 14, 2007 10:23 am 
Regular
Regular

Joined: Mon Mar 26, 2007 12:38 am
Posts: 119
Hi,
>> hql = "select pr.id from PrJournalRoleInfo pr where pr.id=:personId";
>> qry = sess.createQuery(hql);
>> qry.setLong("personId", personId.longValue());


Here, I expect personId to be set an object of class RapidReview.core.hibernate.PrJournalRoleInfoId and not a long value.

RapidReview.core.hibernate.PrJournalRoleInfoId rid = new ..() ;
rid.setPrPersonId(personId.longValue()) ;
rid.setSlNo() ; // some value
qry.setParameter("personId",rid) ;


Confusion:
I am puzzled.
I get ORA-01008: not all variables bound with the original query.
This is because, the sql query that is generated looks like
.....
from AACR20_DBA.PR_JOURNAL_ROLE_INFO prjournalr0_ where prjournalr0_.PR_PERSON_ID = ? AND prjournalr0_.SL_NO=?
....

This is different from your error.
I don't understand the reason.

-------------------------------------------------
Rate the reply if you find it helpful


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 14, 2007 3:22 pm 
Senior
Senior

Joined: Tue Jun 12, 2007 4:49 pm
Posts: 127
Location: India
Quote:
13 Jun 2007 18:34:37 [0_623=WebEcommerceSetup] DEBUG -could not execute query [select prjournalr0_.PR_PERSON_ID as col_0_0_, prjournalr0_.SL_NO as col_0_1_ from AACR20_DBA.PR_JOURNAL_ROLE_INFO prjournalr0_ where (prjournalr0_.PR_PERSON_ID, prjournalr0_.SL_NO)=?]



This and the query in code are not the same. The query in error is selecting 2 columns, while the one in your code is selecting one column.

It looks like some other query is giving this exception, probably the one that runs before it.

Regards,
Jitendra


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 14, 2007 10:46 pm 
Regular
Regular

Joined: Mon Mar 26, 2007 12:38 am
Posts: 119
Hi,
Let me clarify.
In the case under discussion,
i) Oracle error is independent of columns selected.
ii) it is originating from where clause.


Top
 Profile  
 
 Post subject: Re:
PostPosted: Fri Jun 15, 2007 2:37 am 
Senior
Senior

Joined: Tue Jun 12, 2007 4:49 pm
Posts: 127
Location: India
Yes. It is clear that the where clause is incorrect. But so is the query mis-match.

Lets first find the query which is causing this problem then we can worry about correcting the where clause.


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