Hi,
Below SQL is working perfectly....
String sqlString = "UPDATE employee SET employee_status = EXISTS (SELECT employee_status " + "FROM company WHERE employee_id=" + employeeId + " AND employee_status = TRUE) where " + "employee_id= " + employeeId; Query query = currentSession().createSQLQuery(sqlString);
When i converted the above SQL query to below HQL query
Query query = currentSession() .createQuery( "UPDATE Employee SET employeeStatus = EXISTS (SELECT employeeStatus " + "FROM Company WHERE employeeId =:employeeId AND employeeStatus = :employeeStatus) where " + "employeeId = :employeeId"); query.setParameter("employeeStatus", true); query.setParameter("employeeId", employeeId);
Getting the following exception
<AST>:1:79: unexpected AST node: EXISTS <AST>:1:79: unexpected AST node: EXISTS at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.newValue(HqlSqlBaseWalker.java:1227) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.assignment(HqlSqlBaseWalker.java:1033) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.setClause(HqlSqlBaseWalker.java:747) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.updateStatement(HqlSqlBaseWalker.java:367) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:255) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:249)
could someone help me with the correct HQL query ??? Please let me know my mistakes in the HQL Query.
Thanks.
|