问题描述
任何人都可以告诉我Hibernate的区别:
createCriteria
createQuery
createSQLQuery
任何人都可以告诉我这三个函数返回什么数据,cq直接给我一个适当的和简单的链接来学习这些Hibernate函数?
为了在Hibernate ORM框架中创建查询,三种不同类型。以下是创建查询实例的三种方法:
-
session.createQuery()
-
session.createSQLQuery()
-
session.createCriteria ()
仔细查看每个类别的详细信息。
Session.createQuery()
createQuery()方法使用HQL语法创建Query对象。例如:
pre $ Query query = session.createQuery(from Student s where s.name like'k%');
会话.createSQLQuery()
createSQLQuery()方法使用本机SQL语法创建Query对象。例如:
Query query = session.createSQLQuery(Select * from Student);
会话.createCriteria()
方法createCriteria()创建Criteria对象来设置查询参数。对于那些不想编写查询的人来说,这是更有用的功能。您可以使用Criteria API指定任何类型的复杂语法。
Criteria criteria = session.createCriteria(Student.class);
Can anyone please tell me the difference between Hibernate's:
createCriteria
createQuery
createSQLQuery
Can anyone tell me what data these three functions return, c.q. direct me to a proper and simple link to study these Hibernate functions?
To create query in the Hibernate ORM framework, there is three different types. The following are the three ways to create query instance:
session.createQuery()
session.createSQLQuery()
session.createCriteria()
Look into the details of each category in detail.
Session.createQuery()
The method createQuery() creates Query object using the HQL syntax. For example:
Query query = session.createQuery("from Student s where s.name like 'k%'");
Session.createSQLQuery()
The method createSQLQuery() creates Query object using the native SQL syntax. For example:
Query query = session.createSQLQuery("Select * from Student");
Session.createCriteria()
The method createCriteria() creates Criteria object for setting the query parameters. This is more useful feature for those who don't want to write the query in hand. You can specify any type of complicated syntax using the Criteria API.
Criteria criteria = session.createCriteria(Student.class);
这篇关于Hibernate之间的区别createCriteria,createQuery,createSQLQuery函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!