如题。
hql如下:select new com.pb.entity.Customer_HO_Data(c.customer_id, c.customer_name, sum(ho.total_amount)) from Customer c left join c.history_orders ho where 1=1 AND substr(to_char(ho.order_date),0,4) = '2014' group by c.customer_id, c.customer_name order by c.customer_id
控制台输出:select customer0_.CUSTOMER_ID as col_0_0_, customer0_.CUSTOMER_NAME as col_1_0_, sum(history_or1_.TOTAL_AMOUNT) as col_2_0_ from CUSTOMER customer0_ left outer join HISTORY_ORDER history_or1_ on customer0_.CUSTOMER_ID=history_or1_.CUSTOMER_ID where (1=1 )AND(substr(to_char(history_or1_.ORDER_DATE), 0 , 4)='2014' ) group by customer0_.CUSTOMER_ID , customer0_.CUSTOMER_NAME order by customer0_.CUSTOMER_ID
个人感觉是hibernatetemplate的find方法的问题。
控制台输出的sql语句正确,可以在plsql中得到查询结果,但是方法中返回的list结果集为0,请教是哪的问题
答案:3 悬赏:20 手机版
解决时间 2021-03-19 17:36
- 提问者网友:刺鸟
- 2021-03-18 21:18
最佳答案
- 五星知识达人网友:青灯有味
- 2021-03-18 22:39
看了你的追问
你直接用to_char(ho.order_date,'yyyy') = '2014 应该就可以了
你直接用to_char(ho.order_date,'yyyy') = '2014 应该就可以了
全部回答
- 1楼网友:佘樂
- 2021-03-19 01:21
hibernate 好像不支持 left join 吧,反正我们使用的版本不支持 join,你先把left join 去了,看看是不是这个问题。
- 2楼网友:像个废品
- 2021-03-19 00:04
log4j配置中加上log4j.logger.java.sql.connection=debuglog4j.logger.java.sql.preparedstatement=debug顺便配置好你的日志等级就行了
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯