SQL Query Generated with incorrect characters on alias column name

Description

I've the following Entity

Also I've the following Spring JPA Repository:

As you can see, there is a special character on the first column name 'º'. The problem is that, when I call to repo.findOneByCodigo() method, the following SQL is generated:

The problem is that sql gives an error because of the name Hibernate assings to that column: as post_nº_2_2_. The generated SQL should be put inside `` the same way I've put the column name inside the @Column annotation

Aditional Data:

Environment

Java 7, MySQL 5.1.37

Activity

Show:
Jose Miguel Sanz
February 2, 2016, 1:08 PM

As far as I've seen, this would be solved if the alias name was created by the Dialect or, at least, if all aliases be quoted.

The code involved here is located at org.hibernate.mapping.Column on getAlias(Dialect dialect) method. as I said, instead of compose the alias itself, it should be generated or at least allow the Dialect to parse it to generate a valid alias name.

Jose Miguel Sanz
February 2, 2016, 4:16 PM

Moving this issue from Hibernate JPA because this error is global to Hibernate, not just JPA and not just with Spring JPA Repository.

Jose Miguel Sanz
February 2, 2016, 4:19 PM

Another way to fix this would be to quote all column aliases returned by the Column class on the AbstractEntityPersister the same way it quote the column names.

Assignee

Unassigned

Reporter

Jose Miguel Sanz

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Major
Configure