10

Is there a better way to create a SQL null value with CriteriaBuilder than

criteriaBuilder.quot(criteriaBuilder.literal(0), criteriaBuilder.literal(0))

?

mazatwork
  • 1,275
  • 1
  • 13
  • 20

1 Answers1

22

The easiest way is to use the method CriteriaBuilder#nullLiteral() which does exactly that. Since you need a null Integer, use it with Integer Class:

Expression<Integer> expr = criteriaBuilder.nullLiteral(Integer.class);
perissf
  • 15,979
  • 14
  • 80
  • 117