Skip to content

Issue with Updating Field Value Using MyBatis Dynamic SQL #737

@zgqq

Description

@zgqq

I am trying to construct a dynamic SQL query to update the balance field in the user table. The goal is to increment the balance field by a certain value for a specific uid. However, I'm facing difficulties in getting the query to execute correctly.

I am looking to achieve an effect similar to the following code snippet:

   @Update("UPDATE user SET balance = balance + #{balance} WHERE uid = #{uid}")
    void addUserBalance(@Param("uid") Integer uid, @Param("balance") Integer balance);

Attempted Solutions:
I tried using .set(balance).equalToWhenPresent(...) but it didn't work as expected.
Could you please provide some guidance on how to correctly construct this query using MyBatis Dynamic SQL? Any help would be greatly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions