How to find distinct rows with field in list using JPA and Spring?

前端 未结 5 1702
陌清茗
陌清茗 2020-12-01 17:45

I am using Spring to connect to the db. I have an interface extending CrudRepository Here is the query I want execute on the db: SELEC

5条回答
  •  伪装坚强ぢ
    2020-12-01 18:17

    Can you not use like this?

    @Query("SELECT DISTINCT name FROM people p (nolock) WHERE p.name NOT IN (:myparam)")
    List findNonReferencedNames(@Param("myparam")List names);
    

    P.S. I write queries in SQL Server 2012 a lot and using nolock in server is a good practice, you can ignore nolock if a local db is used.

    Seems like your db name is not being mapped correctly (after you've updated your question)

提交回复
热议问题