Hi All!
I am facing the following exception when I execute this query.
Code:
String propertyName= "businessLoginId";
String queryString = "from Amount as model where model."
+ propertyName + "= ?";
Query queryObject = session.createQuery(queryString);
queryObject.setParameter(0, value);
return queryObject.list();
com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near the keyword 'as'.
com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(Unknown Source)
com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(Unknown Source)
org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:120)
org.hibernate.loader.Loader.getResultSet(Loader.java:1272)
org.hibernate.loader.Loader.doQuery(Loader.java:391)
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
org.hibernate.loader.Loader.doList(Loader.java:1593)
org.hibernate.loader.Loader.list(Loader.java:1577)
org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395)
org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)
org.hibernate.impl.SessionImpl.list(SessionImpl.java:844)
org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
eexits.db.AmountManager.findByProperty(AmountManager.java:25)
eexits.db.AmountManager.findByBusinessLoginId(AmountManager.java:32)
eexits.action.SpecialAction.execute(SpecialAction.java:52)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
Please help me. I would be very grateful. Mapping is ok and so is the configuration.