Wednesday, February 10, 2016

Keynotes: Derive JPA query from method name

JPA lookup

The JPA module supports defining a query or native query manually as String (using @NamedQuery/@NativeNamedQuery/@Query annotations) or have it being derived from the method name.

Default lookup strategy is CREATE_IF_NOT_FOUND, which combines combines CREATE and USE_DECLARED_QUERY ones. It looks up a declared query first, and if no declared query is found, it creates a custom method name-based query.
Spring Data repository query building mechanism allows quick query definition by method names & custom-tuning of it by introducing declared queries as needed.

No comments:

Post a Comment