2

I want dynamic filter queries. Example

/api/users?name=xyz

/api/users?name=xyz&email=abc

With spring boot it was possible using JpaSpecificationExecutor, where I could pass custom "Specification". How to do this using micronaut-data?

AmitB10
  • 425
  • 6
  • 16
  • create an repository like that (https://micronaut-projects.github.io/micronaut-data/latest/guide/#repositories) and build the query using the entity manager and JPA criteria API – IEE1394 Jan 21 '21 at 22:05
  • Yes, did the same.. – AmitB10 Jan 22 '21 at 02:34

1 Answers1

1

You can use similar classes with Micronout Data's JPA specifications.

Based on the same concept as Spring Data, when you need to create queries dynamically by composing JPA criteria then you can implement the JpaSpecificationExecutor interface which provides multiple methods that receive an instance of Specification which can be used in combination with existing repository interfaces.

hc_dev
  • 8,389
  • 1
  • 26
  • 38
  • Usually such link-only suggestions can be placed as comment. I added proper formatting plus highlighted same JPA-related classes to make this a easy to read and helpful answer. – hc_dev Nov 18 '21 at 23:22
  • Looks like this was added to Micronaut data recently. When I had asked this question, this was not supported! Thanks for the answer! – AmitB10 Nov 19 '21 at 05:53