Skip to content

Spring Lemon Commons JPA Guide

Sanjay Patel edited this page Jan 12, 2019 · 3 revisions

spring-lemon-commons-jpa includes spring-lemon-commons-web and adds Spring Data JPA to it. It comes with a couple of features, discussed below.

LemonEntity

LemonEntity is a base JPA entity class, with support for auditing, optimistic locking, and permission evaluation. When you need any of these features in an entity, inherit that from this one.

How to execute some code only after successful commit

Sometimes you'll need to execute some code only after a successful database commit. For example, you should send verification mail to a user only after his registration data is committed to the database. Use LecjUtils.afterCommit method in such cases.

How to ensure that some data being updated isn't stale

LecjUtils.ensureCorrectVersion can be used for ensuring some data isn't stale, particularly after an edit request received from front-end. Check out how it's used when editing a user, in LemonService.updateUser.