jpa 相关的sql

1.查询:

@Query(value = "select * from system_action sa where sa.parent_id = ?1 order by parent_id,index_of", nativeQuery = true)
public List<SystemAction> findAllByParentIdOrderByIndexOf(Long parentId);

2.修改:

@Modifying@Query(value = "UPDATE system_action AS per JOIN system_action AS b ON (per.`id` = ?1 AND b.`id` = ?2) SET per.`index_of` = b.`index_of`, b.`index_of` = per.`index_of`", nativeQuery = true)public void swapSort(Long currentId, Long swapId);
2.统计:

public int countByName(String name);

假如我的博客对你有用,请你关注我一下,告诉我你来过,你的关注是我前进的动力,希望更多的人记录自己的问题,去帮助别人更是帮助自己避免再次出现这样那样的问题,谢谢你的来过!
原文地址:https://www.cnblogs.com/zxy-come-on/p/14767847.html