我正在努力做到这一点:
@SQLInsert(sql =
"INSERT INTO table" +
"(colum1,colum2,colum3,colum4,colum5)" +
" SELECT ?,?,?,?,?" +
" WHERE" +
" NOT EXISTS (" +
"SELECT id FROM table WHERE " +
"colum1 = ? " +
"AND colum2 = ? " +
"AND colum3 = ? " +
"AND colum4 = ? " +
"AND colum5 = ? " +
")",
check = ResultCheckStyle.COUNT)
但我得到例外:
ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.RuntimeException: org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; nested exception is
org.hibernate.exception.DataException: could not execute statement] with root cause
org.postgresql.util.PSQLException: No value specified for parameter 18.
我开始认为使用@SQLInsert注释无法实现此功能。女巫是不幸的,因为它应该工作似乎相当干净的问题。