public String getAnnual() {
Date date = new Date();
String dateStr = new SimpleDateFormat("yyyyMM").format(date);
Session session = CommonSessionFactory.getSession();
String year = null;
String hql = "From nesj.Common.CommonFormBean.Accounting account "
+ " WHERE account.startYearMonth <= ? "
+ " AND account.endYearMonth >= ? ";
Query query = session.createQuery(hql);
query.setParameter(1, dateStr);
query.setParameter(2, dateStr);
@SuppressWarnings({ "unused", "unchecked" })
List<Accounting> accountList = query.list();
if (!accountList.isEmpty()) {
year = accountList.get(0).getYear();
System.out.println(year+"shujukuchaxunchule");
CommonSessionFactory.closeSession();
}
Date date = new Date();
String dateStr = new SimpleDateFormat("yyyyMM").format(date);
Session session = CommonSessionFactory.getSession();
String year = null;
String hql = "From nesj.Common.CommonFormBean.Accounting account "
+ " WHERE account.startYearMonth <= ? "
+ " AND account.endYearMonth >= ? ";
Query query = session.createQuery(hql);
query.setParameter(1, dateStr);
query.setParameter(2, dateStr);
@SuppressWarnings({ "unused", "unchecked" })
List<Accounting> accountList = query.list();
if (!accountList.isEmpty()) {
year = accountList.get(0).getYear();
System.out.println(year+"shujukuchaxunchule");
CommonSessionFactory.closeSession();
}
return year;
提示这个错误,还没解决
type Exception report
message Position beyond number of declared ordinal parameters. Remember that ordinal parameters are 1-based! Position: 2
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.hibernate.QueryParameterException: Position beyond number of declared ordinal parameters. Remember that ordinal parameters are 1-based! Position: 2 org.hibernate.engine.query.ParameterMetadata.getOrdinalParameterDescriptor(ParameterMetadata.java:81) org.hibernate.engine.query.ParameterMetadata.getOrdinalParameterExpectedType(ParameterMetadata.java:87) org.hibernate.impl.AbstractQueryImpl.determineType(AbstractQueryImpl.java:445) org.hibernate.impl.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:417) nesj.Common.CommonDao.CommonDaoImpl.getAnnual(CommonDaoImpl.java:56) nesj.C0200.Action.C0201Action.getDayAmountList(C0201Action.java:32) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) java.lang.reflect.Method.invoke(Unknown Source) com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocati