Home > OS >  Looking for spring data jpa query for findall excludung some names from a column
Looking for spring data jpa query for findall excludung some names from a column

Time:06-25

list_Type_code(PK) ListTypeName
CONTRACT cpn
CPN formul

It's a get all endpoint.I need a query to retrieve all data excluding certain names like CPN from column listtypecode.

CodePudding user response:

For your requirement, you have to write a native query in JPA like below:

@Query(nativeQuery = true, value = "select * from {table_name} where {column_name} not in :names}))
List<{entity_name}> findAllByName(@Param("names")Collection<String> names);

Please resolve placeholders accordingly.

CodePudding user response:

Simple approach:

public List<ModelData> findByListTypeCodeNotIn(List<String> codes);

We can use the above specified JPA query naming convention to achieve the desired result.

  • Related