I can illustrate the problem I'm seeing with a simple entity called Person which has a self-join to its parent:
I've written a query using the JPA Criteria API to return a Person with their parent, locking both the child and parent rows:
Using either Hibernate 5.2.2-FINAL or Hibernate 4.3.11-FINAL running on JDK 8, the generated SQL query is corrupted:
I get the same result using JPQL.
This query worked as expected with Hibernate 4.3.11-FINAL running on JDK 7, generating the query:
I've attached a sample TestCase which highlights the problem.
SQL Server 2008 Express jdk8