-->
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.  [ 10 posts ] 
Author Message
 Post subject: QueryException: in expected: against Tandem
PostPosted: Fri Oct 22, 2004 3:38 pm 
Newbie

Joined: Fri Oct 22, 2004 2:54 pm
Posts: 6
Hibernate version:2.1.6

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping package="test">
<class name="Request" table="CCRAIVRQ">
<id name="personId" type="int" column="person_pk">
<generator class="native"/>
</id>
<property name="requestBy" column="requested_by" length="8"/>
</class>
</hibernate-mapping>

try
{
tx = s.beginTransaction();

Query query = s.createQuery("select request.person_pk, request.requested_by from CCRAIVRQ request");

for (Iterator it = query.iterate(); it.hasNext(); )
{
Request rq = (Request) it.next();
System.out.println("Person: " + rq.getPersonId() + " - " + ", was requested by : " + rq.getRequestBy());
}
System.out.println();

tx.commit();
}

Exception in thread "main" net.sf.hibernate.QueryException: in expected: request
[select request.person_pk, request.requested_by from CCRAIVRQ request]
at net.sf.hibernate.hql.FromParser.token(FromParser.java:102)
at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
at net.sf.hibernate.hql.PreprocessingParser.end(PreprocessingParser.java:142)
at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:30)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138)
at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:294)
at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1562)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1533)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1521)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1513)
at test.Main.viewAllRequestFast(Main.java:54)
at test.Main.main(Main.java:90)

Tandem


Top
 Profile  
 
 Post subject: Re: QueryException: in expected: against Tandem
PostPosted: Fri Oct 22, 2004 6:17 pm 
Newbie

Joined: Tue Jul 20, 2004 1:25 pm
Posts: 12
<original query>
Query query = s.createQuery("select request.person_pk, request.requested_by from CCRAIVRQ request");
</original query>


You are constructing an Hql query, not a SQL query so your query should be referring to the class not the table. Try this query:

select req.person_pk, req.requested_by from request req


Top
 Profile  
 
 Post subject: QueryException: in expected:Tandem
PostPosted: Mon Oct 25, 2004 9:43 am 
Newbie

Joined: Fri Oct 22, 2004 2:54 pm
Posts: 6
I did what you suggest and there is an output:

Exception in thread "main" net.sf.hibernate.QueryException: in expected: req [s
lect req.personId, req.requestBy from request req]
at net.sf.hibernate.hql.FromParser.token(FromParser.java:102)
at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
at net.sf.hibernate.hql.PreprocessingParser.end(PreprocessingParser.jav:142)
at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:30)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:14)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:13)
at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpljava:294)
at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1562)
at net.sf.hibernate.impl.SessionImpl.iterate(SessionImpl.java:1592)
at net.sf.hibernate.impl.QueryImpl.iterate(QueryImpl.java:27)
at test.Main.viewAllRequestFast(Main.java:57)
at test.Main.main(Main.java:91)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 25, 2004 11:05 am 
Newbie

Joined: Tue Oct 21, 2003 1:09 pm
Posts: 4
This is strsight forward
u gave the "req" as alias for the Request Object so you have to use that in select part. Use req.personId, req.requestBy instead of request.personId, request.requestBy

Thanks

Hans


Top
 Profile  
 
 Post subject: QueryException: in expected: against Tandem
PostPosted: Mon Oct 25, 2004 12:24 pm 
Newbie

Joined: Fri Oct 22, 2004 2:54 pm
Posts: 6
I know it is very simple stuff but I am new in Hibernate.
Yes I forgot to change my sql. So now I am getting this:
SEVERE: SQLMP Error: Syntax error
Oct 25, 2004 9:28:48 AM net.sf.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: -3015, SQLState: null
Oct 25, 2004 9:28:48 AM net.sf.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: SQLMP Error: Syntax error
Oct 25, 2004 9:28:48 AM net.sf.hibernate.JDBCException <init>
SEVERE: Could not execute query
java.sql.SQLException: SQLMP Error: Syntax error
at com.tandem.sqlmp.SQLMPPreparedStatement.<init>(SQLMPPreparedStatement.java:155)
at com.tandem.sqlmp.SQLMPConnection.prepareStatement(SQLMPConnection.java:422)
at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:257)
at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:232)
at net.sf.hibernate.impl.BatcherImpl.prepareQueryStatement(BatcherImpl.java:65)
at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:779)
at net.sf.hibernate.hql.QueryTranslator.iterate(QueryTranslator.java:864)
at net.sf.hibernate.impl.SessionImpl.iterate(SessionImpl.java:1609)
at net.sf.hibernate.impl.QueryImpl.iterate(QueryImpl.java:27)
at test.Main.viewAllRequestFast(Main.java:57)
at test.Main.main(Main.java:91)
Exception in thread "main" net.sf.hibernate.JDBCException: Could not execute query
at net.sf.hibernate.impl.SessionImpl.iterate(SessionImpl.java:1612)
at net.sf.hibernate.impl.QueryImpl.iterate(QueryImpl.java:27)
at test.Main.viewAllRequestFast(Main.java:57)
at test.Main.main(Main.java:91)
Caused by: java.sql.SQLException: SQLMP Error: Syntax error
at com.tandem.sqlmp.SQLMPPreparedStatement.<init>(SQLMPPreparedStatement.java:155)
at com.tandem.sqlmp.SQLMPConnection.prepareStatement(SQLMPConnection.java:422)
at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:257)
at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:232)
at net.sf.hibernate.impl.BatcherImpl.prepareQueryStatement(BatcherImpl.java:65)
at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:779)
at net.sf.hibernate.hql.QueryTranslator.iterate(QueryTranslator.java:864)
at net.sf.hibernate.impl.SessionImpl.iterate(SessionImpl.java:1609)
... 3 more

Does that have to anything to do with special settings....


Top
 Profile  
 
 Post subject: QueryException: in expected: against Tandem
PostPosted: Wed Oct 27, 2004 12:15 pm 
Newbie

Joined: Fri Oct 22, 2004 2:54 pm
Posts: 6
does anybody work with Tandem and have Hibernate working with.
Please help me out.


Top
 Profile  
 
 Post subject: Re: QueryException: in expected: against Tandem
PostPosted: Thu Oct 28, 2004 2:52 pm 
Expert
Expert

Joined: Thu Jan 08, 2004 6:17 pm
Posts: 278
puppydog wrote:
does anybody work with Tandem and have Hibernate working with.
Please help me out.


Turn on SQL logging in Hibernate and you'll see exactly what SQL is making Tandem unhappy.

Cheers,
Rob


Top
 Profile  
 
 Post subject: QueryException: in expected: against Tandem
PostPosted: Thu Oct 28, 2004 3:14 pm 
Newbie

Joined: Fri Oct 22, 2004 2:54 pm
Posts: 6
This is the SQL has been created by Hibernate. And it seems to me that Hibernate adds alias for each columns which are not supports by Tandem. Please tell me it is not trueeee and help me.


Hibernate: select request0_.person_pk as x0_0_, request0_.requested_by as x1_0_
from CCRAIVRQ request0_



SEVERE: SQLMP Error: Syntax error
Oct 28, 2004 3:07:19 PM net.sf.hibernate.JDBCException <init>
SEVERE: Could not execute query
java.sql.SQLException: SQLMP Error: Syntax error
at com.tandem.sqlmp.SQLMPPreparedStatement.<init>(SQLMPPreparedStatement
.java:155)
at com.tandem.sqlmp.SQLMPConnection.prepareStatement(SQLMPConnection.jav
a:422)
at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.ja
va:257)
at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.ja
va:232)
at net.sf.hibernate.impl.BatcherImpl.prepareQueryStatement(BatcherImpl.j
ava:65)
at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:779)
at net.sf.hibernate.hql.QueryTranslator.iterate(QueryTranslator.java:864
)
at net.sf.hibernate.impl.SessionImpl.iterate(SessionImpl.java:1609)
at net.sf.hibernate.impl.QueryImpl.iterate(QueryImpl.java:27)
at test.Main.viewAllRequestFast(Main.java:57)
at test.Main.main(Main.java:92)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 28, 2004 4:15 pm 
Expert
Expert

Joined: Thu Jan 08, 2004 6:17 pm
Posts: 278
Unfortunately I think it is trueeee.

Hibernate uses aliases very heavily in every dialect I've seen (Oracle, MySQL, and Postgres).

If there is not a Tandem-specific dialect already you may well have to write one that doesn't use aliases. (wow, I've never heard of a SQL database that didn't support aliases)

Cheers,
Rob


Top
 Profile  
 
 Post subject: QueryException: in expected: against Tandem
PostPosted: Thu Oct 28, 2004 4:47 pm 
Newbie

Joined: Fri Oct 22, 2004 2:54 pm
Posts: 6
I am so disappoint I was wondering if I could hide all that work with
JDBC, but....
Yes Hibernate does not have dialect for TANDEM and it seems like nobody
have done anything against Tandem.
I am so .....
Thank you and do not do what I would not doooooo


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