Comparison of SQL, HQL, JPQL, CQL

Source: Internet
Author: User

SQL: Full-Name Structured Query Language (structured Query Language), a special purpose programming language, is a database query and programming language for accessing data and querying, updating and managing relational database systems , and is also the extension of the database script file.

HQL: HQL (Hibernate query Language) query provides richer and more flexible query properties than the criteria query. As a result, Hibernate makes the HQL query the official recommended standard Query method, HQL query to cover all the functions of the criteria query, provides a similar standard SQL statement query method, but also provides a more object-oriented encapsulation.

JPQL: In Java EE, JPQL is designed specifically for Java applications to access and navigate entity instances. Java presistence Query Language (JPQL), Java persistent querying language. JPQL is a query language, with features similar to SQL, JPQL is completely object-oriented, with inheritance, polymorphism and association characteristics, and hibernate hql very similar.

CQL: All called Cloud Query Language, is a subset and variant of SQL query syntax, designed to allow developers to query Leancloud cloud data using traditional SQL syntax to reduce learning Leancloud query A The cost of PI.

comparison of different points :

1.SQL and HQL:

SQL database-oriented table query
HQL Object-oriented query
Hql:from followed by class name + Class object where to use the property of the object to do the condition
Sql:from followed by the table name where to use the field in the table to make the condition
Query: When you use queries in Hibernate, you typically use HQL query statements, and you need to be aware of the following when using HQL:
(1) Case sensitive. Because HQL is object-oriented, and the name and properties of an object class are case-sensitive, hql is case-sensitive.
such as: HQL statement: from Cat as Cat where cat.id > 1; Unlike the From Cat as Cat where cat.id > 1; is not the same as SQL.
(2) FROM clause. From cat, the sentence returns an instance of the Cat object, which the developer can also alias, eg. From Cat as Cat. For multi-table queries, refer to the following:
From Cat as Cat, dog as dog.

2.SQL and JPQL:

JPQL is an object-oriented query language, so it can fully understand the characteristics of inheritance, polymorphism, and correlation. And JPQL has built-in a lot of functions, greatly facilitates the function of JPQL query. Of course JPQL is still SQL-based, but the JPQL-to-SQL conversion does not need to be a developer's concern, and the JPQL parser is responsible for completing this transformation, and is responsible for executing the SQL statement to update the database.
SQL is a query language for relational databases, so the objects for SQL operations are data tables, data columns, and objects that JQPL manipulate are entity objects, object properties.

3,SQL and CQL: The difference between CQL and SQL is mainly reflected in the following points:

    • Adding aliases to columns with the AS keyword in select is not supported.
    • Update and delete do not provide bulk updates and deletions, only where objectId=xxx updates or deletes a document based on ObjectId () and other criteria.
    • Not supported join , associated query provides include , and relatedTo so on syntax substitution (relational query).
    • Only partial SQL functions (built-in functions) are supported.
    • Does not support,,,, group by having , and max min sum distinct so on group aggregation query syntax.
    • Transactions are not supported.
    • Locks are not supported.

This article refers to: 78378995?foxhandler=rssreadrenderprocesshandler

https://leancloud.cn/docs/cql_guide.html#hash-906021636

Comparison of SQL, HQL, JPQL, CQL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.