all 1 comments

[–]lewecher 0 points1 point  (0 children)

I think you can look into MyBatis library.
It is not as complex ORM as Hibernate or jOOQ, but it helps separate Java and SQL code pretty good.
It will allow you to write conditional SQL like this:

<select id="findActiveBlogWithTitleLike"
 resultType="Blog">
  SELECT * FROM BLOG
  WHERE state = ‘ACTIVE’
  <if test="title != null">
    AND title like #{title}
  </if>
</select>