public static Double FindBatchTakenForMonthAndProduct(String ProductID, String location
, String status, String fromDate) {
return entityManager().createQuery("Select SUM(a.BadReqBatchSize) as BATCH_TAKEN " +
"from BatchDetails a,
(SELECT b.BahSeqNo, c.BahIssueDate, b.BahLocId, " +
"c.BahIssueRmRefNo, b.BahRmRefNo from BatchHeader b, BatchIssueHeader c " +
" where c.BahIssueSeqNo = b.BahSeqNo and c.BahIssuePrdId=b.BahPrdId " +
"and c.BahIssueRmRefNo=b.BahRmRefNo " +
"and b.BihWipYn = '0' and c.BahIssueExtYn='0' and b.BahLocId = '"+location
+"' and c.BahIssueStsId = '"+status+"' ) as e "
+"where a.BadBahSeqNo = e.BahSeqNo and a.BadPrdId = '"+ProductID
+"' and e.BahIssueDate >= '"+fromDate+"' GROUP BY a.BadPrdId"
, Double.class).getSingleResult();
}
Above query gives following errors:
2013-08-03 16:55:31,138 [tomcat-http--23] ERROR org.hibernate.hql.PARSER - line 1:108: unexpected token: (
2013-08-03 16:55:31,138 [tomcat-http--23] ERROR org.hibernate.hql.PARSER - line 1:188: unexpected token: from
2013-08-03 16:55:31,139 [tomcat-http--23] ERROR org.hibernate.hql.PARSER - line 1:251: expecting OPEN, found '.'
Last error (expecting OPEN, found '.' ) can be due to POJO package name. If it is in.myproject.myname, HQL takes in as the SQL Keyword IN and looks for OPEN '('.
Can't change the pkg name as it is the standard for our proj; so what can be alternative solution??
Error message on browser is as follows:-
org.hibernate.hql.ast.QuerySyntaxException: unexpected token: ( near line 1, column 108 [Select SUM(a.BadReqBatchSize) as BATCH_TAKEN from in.traccion.aristo.bsrtransaction.domain.BatchDeta ils a, (SELECT b.BahSeqNo, c.BahIssueDate, b.BahLocId, c.BahIssueRmRefNo, b.BahRmRefNo from in.traccion.aristo.bsrtransaction.domain.BatchHead er b, in.traccion.aristo.bsrtransaction.domain.BatchIssu eHeader c where c.BahIssueSeqNo = b.BahSeqNo and c.BahIssuePrdId=b.BahPrdId and c.BahIssueRmRefNo=b.BahRmRefNo and b.BihWipYn = '0' and c.BahIssueExtYn='0' and b.BahLocId = 'DAMANLB' and c.BahIssueStsId = 'STS0021' ) as e where a.BadBahSeqNo = e.BahSeqNo and a.BadPrdId = 'PL-D-M-0001-06' and e.BahIssueDate >= '01-JUL-2013' GROUP BY a.BadPrdId];
, String status, String fromDate) {
return entityManager().createQuery("Select SUM(a.BadReqBatchSize) as BATCH_TAKEN " +
"from BatchDetails a,
(SELECT b.BahSeqNo, c.BahIssueDate, b.BahLocId, " +
"c.BahIssueRmRefNo, b.BahRmRefNo from BatchHeader b, BatchIssueHeader c " +
" where c.BahIssueSeqNo = b.BahSeqNo and c.BahIssuePrdId=b.BahPrdId " +
"and c.BahIssueRmRefNo=b.BahRmRefNo " +
"and b.BihWipYn = '0' and c.BahIssueExtYn='0' and b.BahLocId = '"+location
+"' and c.BahIssueStsId = '"+status+"' ) as e "
+"where a.BadBahSeqNo = e.BahSeqNo and a.BadPrdId = '"+ProductID
+"' and e.BahIssueDate >= '"+fromDate+"' GROUP BY a.BadPrdId"
, Double.class).getSingleResult();
}
Above query gives following errors:
2013-08-03 16:55:31,138 [tomcat-http--23] ERROR org.hibernate.hql.PARSER - line 1:108: unexpected token: (
2013-08-03 16:55:31,138 [tomcat-http--23] ERROR org.hibernate.hql.PARSER - line 1:188: unexpected token: from
2013-08-03 16:55:31,139 [tomcat-http--23] ERROR org.hibernate.hql.PARSER - line 1:251: expecting OPEN, found '.'
Last error (expecting OPEN, found '.' ) can be due to POJO package name. If it is in.myproject.myname, HQL takes in as the SQL Keyword IN and looks for OPEN '('.
Can't change the pkg name as it is the standard for our proj; so what can be alternative solution??
Error message on browser is as follows:-
org.hibernate.hql.ast.QuerySyntaxException: unexpected token: ( near line 1, column 108 [Select SUM(a.BadReqBatchSize) as BATCH_TAKEN from in.traccion.aristo.bsrtransaction.domain.BatchDeta ils a, (SELECT b.BahSeqNo, c.BahIssueDate, b.BahLocId, c.BahIssueRmRefNo, b.BahRmRefNo from in.traccion.aristo.bsrtransaction.domain.BatchHead er b, in.traccion.aristo.bsrtransaction.domain.BatchIssu eHeader c where c.BahIssueSeqNo = b.BahSeqNo and c.BahIssuePrdId=b.BahPrdId and c.BahIssueRmRefNo=b.BahRmRefNo and b.BihWipYn = '0' and c.BahIssueExtYn='0' and b.BahLocId = 'DAMANLB' and c.BahIssueStsId = 'STS0021' ) as e where a.BadBahSeqNo = e.BahSeqNo and a.BadPrdId = 'PL-D-M-0001-06' and e.BahIssueDate >= '01-JUL-2013' GROUP BY a.BadPrdId];