JAVA hibernate hql 查询不到数据
Stringhql="fromProcessTrainingRecordpwhereisValid='1'andisFinished='1'andprocessName=...
String hql = "from ProcessTrainingRecord p where isValid='1' and isFinished='1' and processName=:processName ";
if(!Common.isEmpty(userCode))
hql += ("and userCode=:userCode ");
if(startTime != null)
hql += "and startTime>=:startTime ";
if(endTime != null)
hql += "and startTime<=:endTime ";
Query query = this.getSession().createQuery(hql);
query.setString("processName", processName);
if(!Common.isEmpty(userCode))
query.setString("userCode", userCode);
if(startTime != null)
query.setDate("startTime", new java.sql.Date(startTime.getTime()));
if(endTime != null)
query.setDate("endTime", new java.sql.Date(endTime.getTime()));
@SuppressWarnings("unchecked")
List<ProcessTrainingRecord> list = query.list();
return list;
list size 是0 为什么? 数据库用SELECT * FROM MCS_PROCESS_TRAINING_RECORD WHERE IS_FINISHED='1' AND IS_VALID='1' AND PROCESS_NAME='AAA' AND USER_CODE='dba' AND START_TIME>='2013-12-29 00:00:00' AND START_TIME<='2013-12-29 23:59:59' 查出来明明是有数据的呀 展开
if(!Common.isEmpty(userCode))
hql += ("and userCode=:userCode ");
if(startTime != null)
hql += "and startTime>=:startTime ";
if(endTime != null)
hql += "and startTime<=:endTime ";
Query query = this.getSession().createQuery(hql);
query.setString("processName", processName);
if(!Common.isEmpty(userCode))
query.setString("userCode", userCode);
if(startTime != null)
query.setDate("startTime", new java.sql.Date(startTime.getTime()));
if(endTime != null)
query.setDate("endTime", new java.sql.Date(endTime.getTime()));
@SuppressWarnings("unchecked")
List<ProcessTrainingRecord> list = query.list();
return list;
list size 是0 为什么? 数据库用SELECT * FROM MCS_PROCESS_TRAINING_RECORD WHERE IS_FINISHED='1' AND IS_VALID='1' AND PROCESS_NAME='AAA' AND USER_CODE='dba' AND START_TIME>='2013-12-29 00:00:00' AND START_TIME<='2013-12-29 23:59:59' 查出来明明是有数据的呀 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询