-->
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.  [ 3 posts ] 
Author Message
 Post subject: Getting executing query
PostPosted: Tue Jan 04, 2005 3:02 pm 
Regular
Regular

Joined: Thu Jul 29, 2004 11:55 pm
Posts: 75
Hi,

I am running hibernate 2.1.7c and I am having a problem with this executing this query. Here is the sql which runs fine:

select z.surrogate_id from zone z, section s, sectiondevicemap map, device d, linecontroller c where z.surrogate_id = s.zone_id and s.surrogate_id = map.section_id and map.device_address = d.address and map.controller_address = c.address and map.protocol = c.protocol_id and d.controller_id = c.surrogate_id and d.surrogate_id = 21653

Here is the code I am executing for hibernate:

//create the query
StringBuffer queryStr = new StringBuffer();
queryStr.append("select z.surrogate_id from zone z, section s, ");
queryStr.append("sectiondevicemap map, device d, linecontroller c ");
queryStr.append("where ");
queryStr.append("z.surrogate_id = s.zone_id and ");
queryStr.append("s.surrogate_id = map.section_id and ");
queryStr.append("map.device_address = d.address and ");
queryStr.append("map.controller_address = c.address and ");
queryStr.append("map.protocol = c.protocol_id and ");
queryStr.append("d.controller_id = c.surrogate_id and ");
queryStr.append("d.surrogate_id = ");
queryStr.append(location);

try {
beginTransaction();
session = getSession();
query = session.createQuery(queryStr.toString());
query.setCacheable(true);
Long id = (Long)query.uniqueResult();
commitTransaction();
return id;
} catch (HibernateException ex) {
ex.printStackTrace();
rollbackTransaction();
throw new DataException(ex);
} catch (Throwable error) {
error.printStackTrace();
logger.error(error);
throw new DataException(error);
} finally {
closeSession();
}

Here is the exception:

Caused by: net.sf.hibernate.QueryException: in expected: z [select z.surrogate_id from zone z, section s, sectiondevicemap map, device d, linecontroller c where z.surrogate_id = s.zone_id and s.surrogate_id = map.section_id and map.device_address = d.address and map.controller_address = c.address and map.protocol = c.protocol_id and d.controller_id = c.surrogate_id and d.surrogate_id = 21653]
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.token(PreprocessingParser.java:123)
at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:29)
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:295)
at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1571)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1542)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
at net.sf.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:550)
at com.reddline.oms.picksystem.model.PickSystemDataAccessor.getZone(PickSystemDataAccessor.java:119)
... 6 more

Thanks.

chuck


Top
 Profile  
 
 Post subject: Opps, Error executing query
PostPosted: Tue Jan 04, 2005 5:47 pm 
Regular
Regular

Joined: Thu Jul 29, 2004 11:55 pm
Posts: 75
I got the subject incorrect.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 04, 2005 9:14 pm 
Regular
Regular

Joined: Thu Jul 29, 2004 11:55 pm
Posts: 75
Please view error executing SQL... for a better description. My bad.


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