简体   繁体   中英

Hibernate queries - why are they so weird?

I was just looking at console and I notices Hibernate queries are looking werid.

Hibernate: select client0_.id as id1_1_0_, client0_.address as address2_1_0_, client0_.name as name3_1_0_, client0_.client_no as client_n4_1_0_, client0_.ssn as ssn5_1_0_ from clients client0_ where client0_.id=?

Hibernate: select orders0_.CLIENT_ID as CLIENT_I5_1_0_, orders0_.id as id1_0_0_, orders0_.id as id1_0_1_, orders0_.CLIENT_ID as CLIENT_I5_0_1_, orders0_.ORDER_DATE as ORDER_DA2_0_1_, orders0_.ORDER_DESC as ORDER_DE3_0_1_, orders0_.ORDER_NO as ORDER_NO4_0_1_ from ORDERS orders0_ where orders0_.CLIENT_ID=?

Is this some kind of HQL?

Regards.

No. It's not HQL - if you read it carefully, you'll see that it's straight-forward ANSI Sql. It has machine-generated, non-human-friendly column aliases, but it's sql.

Hibernate Query Language(HQL) helps to write Queries in object oriented way.So that we are free to migrate from one data base management system to other. For example MySQL to Oracle DB or vice versa.

The HQL is converted in to SQL by Hibernate. The same happens for Criteria queries too.

For example:

         HQL : from Student
         SQL : select * from student

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