java - How to sort column based on null/not null values using Spring Repository? -


i using spring data mongodb. have requirement want sort on field, show rows null values @ last. in case of sql write following query

select myfield    mytable    order case when myfield null 1 else 0 end, myfield 

but not able find out way sort using pagingandsortingrepository. how define sort object?

want sort asc, , field type string

have @ section 6.3.3 of spring data mongodb type-safe query. can implement querydslpredicateexecutor on repository interface:

public interface personrepository extends mongorepository<person, string>, querydslpredicateexecutor<person> {     // additional finder methods go here  } 

and can use method:

list<t> findall(predicate predicate, orderspecifier<?>... orders); 

the orderspecifier constructor takes nullhandling enumeration parameter can set nullsfirst / nullslast.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -