Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Criteria Api: Create null value with CriteriaBuilder

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

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

?

like image 965
mazatwork Avatar asked Jun 14 '13 14:06

mazatwork


1 Answers

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);
like image 196
perissf Avatar answered Nov 01 '22 08:11

perissf