spring boot 连接postgreSQL,注入过程中的错误
spring boot连接postgreSQL的时候,注入方法一直报错,而删除和查询都没有问题,org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [INSERT INTO USER1(ID, USERNAME, PASSWORD, BIRTHDAY) VALUES(?, ?, ?, ?)]; nested exception is org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of com.light.model.User1. Use setObject() with an explicit Types value to specify the type to use.
at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:99)
at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:99)
报错提示写的很清楚,但是我一直没有注意到,是因为在存储过程中,不能将整个user对象直接传给sql语句,而是要分别将参数注入。
错误代码如下:
正确的写法应该是:
只是一个小问题。