java - Rest api via spring -


i have data mysql in table using condition select query fields isdeleted=0, location=1. how implement in repository , access manager.

public interface foodcourtrepository  extends jparepository<foodcourtentity, long> {     list<foodcaseentity> findbyisdeleted(boolean isdeleted); } 

in access manager

public list<foodcasedo> getallfoodcourt() {     list<foodcaseentity> foodcaselist = foodcourtrepository.findbyisdeleted(false); } 

jpa provides @query write custom query. can define interface called foodcourtrepositorycustom , write custom query below:

public interface foodcourtrepositorycustom {  @query("select fe foodcaseentity fe fe.isdeleted=?1 , fe.location=?2 ")  list<foodcaseentity> findbyisdeletedandlocation(boolean isdeleted, integer location); } 

then extends interface in repository inteface below:

public interface foodcourtrepository  extends jparepository<foodcourtentity, long>, foodcourtrepositorycustom{ list<foodcaseentity> findbyisdeleted(boolean isdeleted); } 

now method available in access manager.

public list<foodcasedo> getallfoodcourt() { list<foodcaseentity> foodcaselist = foodcourtrepository.findbyisdeleted(false); list<foodcaseentity> foodcaselist = foodcourtrepository.findbyisdeletedandlocation(false, 1); } 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -