1

I'm using JPAUpdateClause to update all rows satisfying a BooleanExpression where clause.

BooleanExpression where = myEntity.id.isNotNull();
long updatedCount = update.where(where)
        .set(myEntity.comments, request.getComment())
        .execute();

myEntity.comments is a String.

Is it possible to append request.getComment() when calling set() rather than replacing the existing value?

zmelvin
  • 101
  • 4

1 Answers1

1

Instead of putting request.getComment(), try something like below

Expressions.operation(String.class, Ops.ADD, myEntity.comments, request.getComment())
Ashishkumar Singh
  • 3,580
  • 1
  • 23
  • 41
  • Hi Ashishkumar, thanks for the help! I think you're on the right track with your answer, but I'm one thing. The params for Expressions.operation are Type, Operator, and Expression. How would I represent the two values, myEntity.comments and request.getComments as an Expression? – zmelvin Jul 03 '19 at 19:43