用DetachedCriteria 组装查询条件,咋个生成这样的sql语句了捏? 如果没没条件的话还行 ,一加上条件查询,就会出 where y1_.... 然后就报错:列名 'y1_' 无效上个生成的sql语句
select top 14 this_.id as y0_, this_.CODE as y1_, this_.PROJECT_NAME as y2_, this_.PROJECT_STATE as y3_, this_.PROJECT_CLASS as y4_, this_.CUSTOMER_ID as y5_, this_.CUSTOMER_DEPARTMENT_MAIN as y6_, this_.CUSTOMER_DEPARTMENT_HELP as y7_, this_.CUSTOMER_LINKMAN as y8_, this_.CUSTOMER_LINKMAN_PHONE as y9_, this_.CUSTOMER_CODE as y10_, this_.UNIT_PLAN as y11_, this_.UNIT_PLAN_LINKMAN as y12_, this_.UNIT_PLAN_LINKMAN_PHONE as y13_, this_.SUPERVISOR as y14_, this_.SUPERVISOR_LINKMAN as y15_, this_.SUPERVISOR_LINKMAN_PHONE as y16_, this_.PROJECT_CUSTODIAN as y17_, this_.PROJECT_DEPARTMENT as y18_, this_.PROJECT_DEPARTMENT_CUSTODIAN as y19_, this_.PROJECT_MANAGER as y20_, this_.SAFETY_OFFICER as y21_, this_.QUALITY_INSPECTOR as y22_, this_.LIBRARIAN as y23_, this_.BULIDERS as y24_, this_.MATERIALMAN as y25_, this_.TECHONLOGY as y26_, this_.FILE_TRANSFER as y27_, this_.BUILD_STATE as y28_, this_.COMPANYMANAGE_ID as y29_, this_.PROJECT_DATE as y30_, this_.USER_ID as y31_, this_.ACCESSORY_NAME as y32_ from project this_ where (y1_ like ? and y2_ like ?) order by y1_ descHibernateSQL
select top 14 this_.id as y0_, this_.CODE as y1_, this_.PROJECT_NAME as y2_, this_.PROJECT_STATE as y3_, this_.PROJECT_CLASS as y4_, this_.CUSTOMER_ID as y5_, this_.CUSTOMER_DEPARTMENT_MAIN as y6_, this_.CUSTOMER_DEPARTMENT_HELP as y7_, this_.CUSTOMER_LINKMAN as y8_, this_.CUSTOMER_LINKMAN_PHONE as y9_, this_.CUSTOMER_CODE as y10_, this_.UNIT_PLAN as y11_, this_.UNIT_PLAN_LINKMAN as y12_, this_.UNIT_PLAN_LINKMAN_PHONE as y13_, this_.SUPERVISOR as y14_, this_.SUPERVISOR_LINKMAN as y15_, this_.SUPERVISOR_LINKMAN_PHONE as y16_, this_.PROJECT_CUSTODIAN as y17_, this_.PROJECT_DEPARTMENT as y18_, this_.PROJECT_DEPARTMENT_CUSTODIAN as y19_, this_.PROJECT_MANAGER as y20_, this_.SAFETY_OFFICER as y21_, this_.QUALITY_INSPECTOR as y22_, this_.LIBRARIAN as y23_, this_.BULIDERS as y24_, this_.MATERIALMAN as y25_, this_.TECHONLOGY as y26_, this_.FILE_TRANSFER as y27_, this_.BUILD_STATE as y28_, this_.COMPANYMANAGE_ID as y29_, this_.PROJECT_DATE as y30_, this_.USER_ID as y31_, this_.ACCESSORY_NAME as y32_ from project this_ where (y1_ like ? and y2_ like ?) order by y1_ descHibernateSQL
解决方案 »
- jsp中如何对对foreach进行循环,itmes要怎么写才行
- wireshark或ethereal抓包工具怎么设置时间格式为:2011-10-01 10:44:22
- 关于el 的一个问题,求解
- 互联网架构 是什么?都有哪些?谢谢
- hibernate-extensions生成POJO问题。在线等
- 【分享】关于axis2的RPCServiceClient客户端无法传参问题的解决方案
- 配置好了tomcat连接池,可在javabean中调用却总是报错
- tomcat5 在RH9中设置自动启动的问题
- 如何往JBuilder里添加新的类?
- 那位知道J2EE,具体介绍一下,他有什么好处和特异功能?
- 如何用循环遍历一个类的所有get方法
- 求:J2EE项目做好了如何封装,封装后如何部署到另外一台做服务器的电脑
select * from (select top 14 this_.id as y0_, this_.CODE as y1_, this_.....PROJECT_NAME as y2_ from project this_ ) this_2 where (y1_ like ? and y2_ like ?) order by y1_ desc
select * from (select top 14 this_.id as y0_, this_.CODE as y1_, this_.....PROJECT_NAME as y2_ from project this_ ) this_2 where (y1_ like ? and y2_ like ?) order by y1_ desc
detachedCriteria.add(Restrictions.gt(this.field1, this.param1));
detachedCriteria.setProjection(pList);
detachedCriteria.setResultTransformer(Transformers.aliasToBean(Project.class));
return super.getHibernateTemplate().findByCriteria(detachedCriteria, firstResult, maxResults);然后打印sql语句 就那个样了
嗯 我知道的呀 这样用别名报错 但是这个别名是DetachedCriteria 类根据我组装的查询自己转换成那个样的 不明白怎么回事
嗯 我知道的呀 这样用别名报错 但是这个别名是DetachedCriteria 类根据我组装的查询自己转换成那个样的 不明白怎么回事 原因是sql有自己的执行顺序的SQL Select语句完整的执行顺序:from-->where-->order by-->select
未执行到select,就找不到别名了
改为where (this_.CODE like ? and this_.NAME ?)就行
嗯 我知道的呀 这样用别名报错 但是这个别名是DetachedCriteria 类根据我组装的查询自己转换成那个样的 不明白怎么回事 原因是sql有自己的执行顺序的SQL Select语句完整的执行顺序:from-->where-->order by-->select
未执行到select,就找不到别名了
改为where (this_.CODE like ? and this_.NAME ?)就行原来这样 学习了