migue/liferay-portal — pull request #106 by epgarcia (2012-12-24 09:38:38+00:00)
Title: LPS-31033 Change Query to SQLQuery in ServiceBuilder

Hey Migue,

I have modified the Service Builder so that only query objects of the type org.hibernate.SQLQuery are used. This should solve the issues described at LPS-31033. Below I explain the changes I've done:

- Make sure the column DBName is used in SQLQueries, instead of the column name. The first is the actual name of the column in the DB, whereas the second may differ from the first if the column is escaped.
- Use the column DBName as order by fields in OrderByComparators, instead of the column name. I found some comparators where DBName was already being used, but others where we used the name (I changed those).
- Make sure that table aliases are not reserved words (they are not escaped automatically with SQLQuery). I noticed that some of the bad table names where not included in the bad_alias_names.txt file and I included them.
- Remove JPQL ordering logic, since it cannot be used with SQLQuery.
- Replace Query by SQLQuery in the templates for the *PersistenceImpl classes and refactor it to reduce redundant code.
- Extend the template for Persistence Tests with testFindAllOrderBy. This test checks that the order by clause is working for any column in the table. This test only checks that no exception is thrown.
- Undo the temporary changes that the D&M team performed in LPS-30789 (remove hidden from the bad column name list) to unblock their tests, since the above described changes solve the root cause of the issue.
- Regenerate services.

I have run all integration test locally as well as some basic manual test and I have observed no errors. Nevertheless, I'd ask you to review my changes and to run the tests again in the integration test server, to make sure my solution is not breaking anything.

Thanks

@brianchandotcom
@sergiogonzalez
@shuyangzhou