We deployed our application on two WebSphere servers. On first one, we deploy EAR file. On the other one, we create projects and deploy. All the business methods accessing database are working on both servers except one which involves two tables. This particular query runs on the server where we have deployed EAR file. However it gives Unexpected Token error on the other server.
The code snippet:
final String GET_GRANTABLE_BANKS = "select c from Bank as c where c.bankUID NOT IN " + "(select a.bankID from CustomerBank as a) and " + "c.approvalCode = :approvalCode";
final String APPROVAL_CODE = "approvalCode";
Iterator itrBank = null;
try
{
if(log.isDebugEnabled())
{
log.debug("Entering Method " + METHOD_NAME);
log.debug("Input Parameter Session " + session);
}
if((null != session) && (null != approvalCode))
{
//Set the query for getting the Banks.
query = session.createQuery(GET_GRANTABLE_BANKS);
query.setEntity(APPROVAL_CODE,approvalCode);
itrBank = query.list().iterator();
}
Bank and CustomerBank are two Java classes representing two tables. Error happens on the last line itrBank = query.... The exact error message is:
The following exception was logged net.sf.hibernate.QueryException: unexpected token: as [select c from Bank as c where c.bankUID NOT IN (select a.bankID from CustomerBank as a) and c.approvalCode = :approvalCode]
at net.sf.hibernate.hql.FromParser.token(FromParser.java:94)
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:293)
at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1530)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1501)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
|