Exception due to unnecessary alias increment creating hpql

Description

Attempting a criteria query for member routeCreatorId with a value of 1L (whether the row exists in the table or not) I get the following exception.

Invalid path: 'generatedAlias1.routeCreatorId' [select generatedAlias0 from com.linovation.trainapp.database.entities.Route as generatedAlias0 where generatedAlias1.routeCreatorId=1L]

Tracing the Hibernate code into CriteriaCompiler.generateAlias(), the generated alias is incremented when it shouldn't be. The rest of the query construction seems fine until it gets to the where clause. If I set a breakpoint & force aliasCount to be zero before the assignment, the query is created properly, as follows.

select generatedAlias0 from com.linovation.trainapp.database.entities.Route as generatedAlias0 where generatedAlias0.routeCreatorId=1L

select route0_.ROUTE_ID as ROUTE_ID1_4_, route0_.LAST_UPDATED as LAST_UPD2_4_, route0_.DESCRIPTION as DESCRIPT3_4_, route0_.GUID as GUID4_4_, route0_.ROUTE_CREATOR_ID as ROUTE_CR5_4_, route0_.ROUTE_NAME as ROUTE_NA6_4_ from Route route0_ where route0_.ROUTE_CREATOR_ID=2

Is this a defect in your code, or am I doing something wrong? Either way, how does this get fixed?

Environment

hibernate-core 4.3.10 Final
hibernate-entitymanager 4.3.10 Final
h2 1.4.187

Activity

Show:
Andrew Gufford
August 20, 2015, 7:02 PM

Any updates on this?

Gail Badner
August 22, 2015, 12:14 AM

Environment shows hibernate-core 4.3.10 Final and hibernate-entitymanager 4.3.1 Final. Are you really using different versions for hibernate-core and hibernate-entitymanager? I suspect hibernate-entitymanager 4.3.1 Final is a typo and the version is really 4.3.10 Final.

Please confirm.

Andrew Gufford
August 23, 2015, 4:15 PM

It was indeed a typo, from my pom.xml

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.10.Final</version>
</dependency>

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.10.Final</version>
</dependency>

Steve Ebersole
October 27, 2015, 7:16 PM

This bug report does not indicate that the reported issue affects version 5.x. Versions prior to 5.x are no longer maintained. It would be a great help to the Hibernate team and community for someone to verify that the reported issue still affects version 5.x. If so, please add the 5.x version that you verified with to the list of affected-versions and attach the (preferably SSCCE) test case you used to do the verification to the report; from there the issues will be looked at during our triage meetings.

For details, see http://in.relation.to/2015/10/27/great-jira-cleanup-2015/

Steve Ebersole
October 28, 2015, 3:25 AM

As part of verifying that this issue affects 5.0, please just set the "Affects version". Leave the "verify-affects-5.0" label and leave the issue in "Awaiting Response" status; these are critical for us to be able to track these verifications and triage them. Thanks.

Assignee

Unassigned

Reporter

Andrew Gufford

Fix versions

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure