【发布时间】:2018-03-20 11:21:20
【问题描述】:
我有一个 SpringBoot 应用程序和一个从 PagingAndSortingRepository 扩展的界面
用这个方法
@Query(value = "select cp.price, cp.update_date from t_hotel_price cp where cp.hotel_id = ?1 and cp.update_date between ?2 and NOW() order by cp.price ASC LIMIT 1", nativeQuery = true)
Object[] getMaxPriceAndDate (Long hotelId, Date aggregationDate);
来自 JunitTests
Object[] priceAndDate = hotelPriceService.getMaxPriceAndDate(currency.getId(),DateUtils.weeklyDate());
System.out.println
(priceAndDate[0]);
System.out.println
(priceAndDate[1]);
期望 priceAndDate[0] 中的价格和 priceAndDate[1] 中的日期
但是我得到了一个java.lang.ArrayIndexOutOfBoundsException: 1
【问题讨论】:
-
如果您调试该代码会发生什么?你能转储
priceAndDate看看它包含什么吗?
标签: mysql sql spring-boot spring-data spring-data-jpa