仅限本地查询。
示例代码:
@Repository
public interface ItemRepository extends JpaRepository<Item, Long> {
@Query(value = "select max(price) as maxPrice from item_history where itme_id = ?1 limit 1;", nativeQuery = true)
MaxPrice maxPrice(int id);
interface MaxPrice{
Integer getMaxPrice();
}
}
ItemRepository.MaxPrice maxPrice = itemRepository.maxPrice(1);
为什么“ maxPrice”不为null,而是“ maxPrice.getMaxPrice();”返回null?