Requesting this issue be re-opened. It is still present in Hibernate-4.3.7.Final w/ Postgres 9.2.6 using the PostgreSQL9Dialect. The original reporter is exactly right in the trace of what happens.
The fundamental problem is that PostgreSQL9Dialect and its parent type PostgreSQL81Dialect do not override Dialect's: public String getForUpdateString(String aliases, LockOptions lockOptions)
Dialect's implementation doesn't do anything with the alias locks to effect the SELECT ... FOR UPDATE OF x,y,z and will instead render just SELECT .. FOR UPDATE which can cause big problems for queries involving OUTER JOINS which will cause SQL errors in Postgres. The Postgres Dialects have a correctly implemented method getForUpdateString(String aliases) but that isn't called from Dialect's getForUpdateString(String aliases, LockOptions lockOptions).
I suggest PostgreSQL81Dialect override Dialect.getForUpdateString(String aliases, LockOptions lockOptions) In the interim anyone can extend any of the Postgres dialects and override it yourself and it will work.
// If extending Postgres Dialect @Override public String getForUpdateString(String aliases, LockOptions lockOptions) { return super.getForUpdateString(aliases); // Parent implements this correctly }
Sorry to post a solution but no test case.
|