Domain JPA search with criteria, generic/reflection based Specifications?

152 views
Skip to first unread message

manos

unread,
Mar 23, 2013, 4:54:56 AM3/23/13
to resthub-dev
I'm trying to figure out a nice way to implement a generic criteria
based search for any domain entity. In other words, I would like a
base implementation to handle arbitrary search terms in URLs like

/api/class?classMember1=value1&classMember2=value2

without knowing the HTTP params or the domain classes those correspond
to beforehand. Does something like the following make sense?

1) Enchance resthub'ss RestController (or my base controller?)
findPaginated signature to add a request parameter (used to obtain the
request parameter map)

2) use the parameter map with generics/reflection to build the JPA
query e.g. in the form of a
org.springframework.data.jpa.domain.Specifications

3) Add a new method to resthub's CrudService to use such a
Specifications parameter

Page<T> find(Specifications specifications, Pageable pageRequest);

I would appreciate any input or alternatives on the above.

Manos

manos

unread,
Jan 21, 2014, 8:42:16 PM1/21/14
to resth...@googlegroups.com
Just realized i never updated here, you can find my implementation at

https://github.com/abissgr/calipso-hub/tree/master/calipso-hub-framework#dynamic-jpa-search-module

Baptiste Meurant

unread,
Jan 22, 2014, 4:13:32 AM1/22/14
to resth...@googlegroups.com
Thank you for that ... sounds great ! 

I will take a closer look soon

Baptiste
Reply all
Reply to author
Forward
0 new messages