简体   繁体   中英

Query generated by Hibernate

I have my service up and running but there's still a few things i can't figure out.

I have a query that is similar to the following

@Query("SELECT t FROM Tablename t")

Then hibernate will generate the following query

Hibernate: select tname.column1 as a, tname.column2 as b, tname.column3 as c, tname.column4 as d from tablename tname

The problem is that Tablename is case sensitive when i query against a mysql database. Is there a way in hibernate to execute the query exactly the way it is spelled out in the annotation? Also, is it possible to stop hibernate from breaking camelcased columns into two works. For example if i had a column named columnOne hibernate will want to generate a column with the name column_one.

I know this more than likely has something to do with hibernate's naming strategy but i haven't been able to find a solution.

Try adding the following in your application.properties file.

 spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl

Documentation about naming strategies are here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM