sql - Spring Boot JPA Query for not null -
i'm using spring boot jpas , want return values status id not null. what's best way query this?
domain
@manytoone @joincolumn(name = "entity_status_id") private entitystatuslookup entitystatuslookup;
entitycontroller
public interface entityrepository extends crudrepository<batch, string> { public page<entity> findbyuploaduserorderbyuploaddatedesc(string userid, pageable page); public entity findbyentityid(string entityid); }
api
@requestmapping(value="/entity/user", method=requestmethod.get) public httpentity<pagedresources<entity>> getentitybyuser(pageable page, pagedresourcesassembler assembler) { string user = securitycontextholder.getcontext().getauthentication().getname(); page<enity> entityitems = entityrepository.findbyuploaduserorderbyuploaddatedesc(user, page); return new responseentity<>(assembler.toresource(entityitems), httpstatus.ok);
i realize loop through returned pages , nulls remove, i'd rather have query return values not null. i'm not sure best way query not null on entity status id.
you can in interface
public interface entityrepository extends crudrepository<batch, string> { iterable<entity> findbystatusidnotnull(); }
see the docs more options
Comments
Post a Comment