customization - JPA custom findOne and findAll -
i have table place contain column "state" (it enum can 'active' or 'inactive')
i know if there way jpa2 when call placerepository.findall() or placerepository.getone(id) select row in database marked "active" ?
something
list<place> findbystateactiveonly();
edit: bonus question: i'am @ moment refactoring project able add place (and other entities) in pending state. because have added column "state" have add queries condition "and p.state=my.package.state.active"
this;
@query("select p place p p.idplace = ?1 , p.state=my.package.state.active")
isn't there way tell jpa automatically select me if state active ?
thank you!
with hibernate, can try annotating entity @where, this
@entity @where(clause = "state = 'active'") public class place {...}
Comments
Post a Comment