Search code examples
javah2jdbi

jDBI and H2 not playing nicely with escaping `<`


I have a query in my @SqlUpdate that uses a < character so this is escaped:

@SqlUpdate(
    "... DateCreated \\< (NOW() - INTERVAL 7 DAY) ..."
)

This works fine in my real production env, but when I try to run a test for it using H2 in-memory database, I get

org.skife.jdbi.v2.exceptions.UnableToCreateStatementException: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement

How do I fix this?


Solution

  • I had this problem too. Put one back slash worked for me. ...DateCreated \< (NOW() - INTERVAL 7 DAY)... Don't know if JDBI can support it in some other way, this workaround is not nice.