HQL时间段查询
来源:互联网 发布:淘宝直通车掌柜热卖 编辑:程序博客网 时间:2024/05/29 16:43
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: 2org.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
0 0
- HQL时间段查询
- hql查询日期时间段及时区问题
- mysql的hql语句之时间段查询
- hibernate查询的时间段选择查询的hql语句总结
- Hibernate中使用Hql查询出一定时间段的记录
- 时间段查询
- HQL查询
- HQL查询
- hql查询
- HQL查询
- hql 查询
- HQL查询
- HQL查询
- hql 查询
- hql查询
- HQL查询
- HQL查询
- hql查询~
- python signal handling
- 通知的各种实用写法技巧
- 数据存取之SQLite浅析
- 创建类的对象
- Flip Game(DFS枚举)
- HQL时间段查询
- Android中五中存储方式的区别和优劣性
- 【驱动开发】006 系统时间
- Centos6.5服务器配置nginx的https证书
- 浅谈Content Provider
- signals linux
- 面试问题
- acm网络一赛 1231:rabbit Composite number【简单合数】
- Android经典71道笔试题,命中率超大!