Showing posts with label Hibernate. Show all posts
Showing posts with label Hibernate. Show all posts
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.
Wednesday, October 28, 2015

Storing created & last updated properties

Created & Last Updated properties

Whenever u're dealing with some accounts, transactions, product items, notes, reviews, etc. it's always useful to know when those where created & last updated/edited/modified.

Notice, that it's always better to fill such properties on the Back-End side rather than on the Front-End. Otherwise, the client can exchange the data & try to store some invalid values. Actually even if the client will send the valid dates, those will not reflect exact time when the data was added in the DB.