问题
When I run a query on hsqldb (1.8.0.7) in mem mode using hibernate (4.2.3.Final) I get the following exception
java.sql.SQLException: Unexpected token: FOR in statement [SELECT *
FROM MYTABLE where ID=? FOR UPDATE NOWAIT] at
org.hsqldb.jdbc.Util.throwError(Unknown Source) at
org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source) at
org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source) at
...
does hsqldb support select from update?
回答1:
In the updatability section of the documentation for 2.3 states that it is somehow supported:
If the SQL qualifier, FOR UPDATE is used, then all the updatable columns of the result set become updatable.
But I haven't been able to find it in the doc for 1.8. I found some sites, like this, saying that SELECT FOR UPDATE is not supported in version 1.8.
No concurrent migration support (to make Flyway cluster-safe) with Hsql 1.8, as this version does not property support SELECT ... FOR UPDATE locking
回答2:
SELECT FOR UPDATE
is fixed in HSQLDB 2.3.3.
However NOWAIT will be fixed as noted HSQLDB 2.3.3 NOWAIT
来源:https://stackoverflow.com/questions/18052406/select-for-update-in-hsqldb-using-hibernate