Malformed SQL query sent to SQL Server with left outer join and pessimistic lock

Description

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.

Environment

Hibernate 5.2.2-Final
SQL Server 2008 Express jdk8

Status

Assignee

Andrea Boriero

Reporter

Chris Abrams

Fix versions

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Minor
Configure