@OrderBy produces incorrect SQL when used on a collection field.

Description

I have a test case - a set of maven projects based on a current project of mine, but simplified a bit for the purpose of demonstrating the problem - that shows that when an @OrderBy is placed on a collection field, incorrect SQL is produced for the MySQL dialect. I was previously working fine when using Hibernate 4.3.0.Beta3, and 4.3.0.Beta3 seems to also work, so the regression seems to be in 4.3.0.Beta5 and artifacts up to 4.3.0.CR2 seem to also be broken. The domain object in question is named Device, and the field with the @OrderBy that fails is deviceProperties. As given, the unit tests for the testcase project should fail, and show the error in the build output. A few things to note... you need a mysql instance set up (I'm using 5.7), by default on localhost and port 3306, and a blank database named hibernate_testcase_1. The maven project should create the schema using flyway, then build the project and run the unit test. A few other things to note about the project setup. You customize the project to use custom mysql parameters, like mysql root user's password, for your environment, by setting up a maven <profile> section (active by default, or activated from the command line if desired) for the following default properties:

<testcase.mysql.server>localhost</testcase.mysql.server>
<testcase.mysql.port>3306</testcase.mysql.port>
<testcase.mysql.admin.user>root</testcase.mysql.admin.user>
<testcase.mysql.admin.pass>root</testcase.mysql.admin.pass>
<testcase.mysql.user>testcaseuser</testcase.mysql.user>
<testcase.mysql.pass>testcaseuser</testcase.mysql.pass>
<testcase.mysql.dbname>hibernate_testcase_1</testcase.mysql.dbname>

Also, the project uses our maven nexus repository. If you wish to NOT customize the maven parent POM file to use your own maven repository, then you'll need to set up your settings.xml with the following <server> sections:

<servers>
<server>
<id>public</id>
<username>guest</username>
<password>viewonly</password>
</server>
<server>
<id>public-snapshots</id>
<username>guest</username>
<password>viewonly</password>
</server>
</servers>

This should get you read-only access (for now, until I lock it back down) to our nexus instance. If you use the eclipse launcher(s) included with the project, a maven trustStore included with the project will be used. See that launcher's definition to help you set up the MAVEN_OPTS (quick hint, the mavenTrust.jks file is in the launchers directory of the parent project) to use that trustStore so there are no SSL errors when maven tries to connect to our nexus instance since we're using self-signed certificates if you want to build the maven project from the command line instead of from eclipse.

One other note... you can quickly check that it works in 4.3.0.Beta3 or 4.3.0.Beta4 by changing the version in the parent pom file (look in properties section).

Please let me know if there is any other information I can provide to help this along or if for some reason I've left out steps or information you need in order to build the project.

It would be great if this could be fixed by the time you release 4.3.0.Final.

Environment

Mac OSX, MySQL 5.7, Eclipse Kepler, Maven 3.0.5 (or eclipse embedded maven version), Hibernate 4.3.0.CR2, MySQL Connector 5.1.25

Assignee

Unassigned

Reporter

Kendal Montgomery

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