SELECT FOR UPDATE in hsqldb using hibernate

时间秒杀一切 提交于 2019-12-23 18:52:16

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!