I usually do ‘select’ query before ‘update’ or ‘insert’ query using Jpa, Java.

For example, I must create new entity if the entity is null by ‘select’ query, or I do just setAge(); if the entity exists.

So I code as below by most commonly.

I don’t want to do it, checking null, always. It is very pesky pattern.

So I create a utility class as below.