Use $ and # in MyBatis to refer to the data passed in,
The difference between the two is:
1. Use # to handle incoming values as strings, and automatically add single quotes to the resulting SQL statement
2. Use $ to directly reference the value passed in (the resulting SQL statement does not enclose a single quotation mark)
3. Using $ easy to cause SQL injection
The problem I encountered:
When using the PostgreSQL database to store data, error:
Error updating database. Cause:org.postgresql.util.PSQLException: Error: The type of the field "message" is JSON, but the type of the expression is character varying
Recommendation: You need to rewrite or convert an expression
The reason for the error is that #{message} is used to reference the message, and the type of the argument becomes a string (the actual type in the database should be JSON)
Use ${message} to resolve
The difference between $ and # in MyBatis