实例
@Query(value = "SELECT max(version) FROM demo where user_id=?1",nativeQuery=true)
int getMaxVersion(Long userId);
或者
@Query(value="select "
+ "b.id,"
+ "b.name,"
+ "b.distribute_address,"
+ "p.name as pointName,"
+ "p.code "
+ "from business b left join product p on b.id=p.business_id where b.status=0 order by id desc limit :page,:pageSize",nativeQuery=true)
public List<Object[]> queryBusinessAndProductVos(@Param("page") int page,@Param("pageSize") int pageSize);
或者
@PersistenceContext
EntityManager entityManager;
@Override
public List<Employee> getFirstNamesLikeAndBonusBigger(String firstName, Double bonusAmount) {
Query query = entityManager.createNativeQuery("select e.* from spring_data_jpa_example.bonus b, spring_data_jpa_example.employee e\n" +
"where e.id = b.employee_id " +
"and e.firstname LIKE ? " +
"and b.amount> ? ", Employee.class);
query.setParameter(1, firstName + "%");
query.setParameter(2, bonusAmount);
return query.getResultList();
}
想获取最新内容,请关注微信公众号
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。