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
Java 7, MySQL 5.1.37
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.
Moving this issue from Hibernate JPA because this error is global to Hibernate, not just JPA and not just with Spring JPA Repository.
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.