休眠中过滤器和条件之间的区别 [英] difference between filters and criteria in hibernate

查看:48
本文介绍了休眠中过滤器和条件之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

休眠中的过滤器和条件之间有什么区别?准则用于按大于,小于或等于等来过滤记录.这是一种过滤器.有人可以通过简单的例子告诉我有什么区别

What is the difference between filters and criteria in hibernate? criteria is used to filter the records by greater than,less than or equal etc.It is kind of filters.Can somebody show me what is difference by simple example

推荐答案

简短答案:

  • 使用过滤器,您可以定义一个限制子句,类似于在类和各种集合元素上可用的现有"where"属性.但是,可以对这些过滤条件进行参数化.然后,应用程序可以在运行时决定是否应启用某些过滤器以及它们的参数值应为什么.过滤器可以像数据库视图一样使用,但可以在应用程序内部对其进行参数化.

  • A filter allows you to define a restriction clause similar to the existing "where" attribute available on the class and various collection elements. These filter conditions, however, can be parameterized. The application can then decide at runtime whether certain filters should be enabled and what their parameter values should be. Filters can be used like database views, but they are parameterized inside the application.

Criteria是一种简化的API,用于通过组合Criterion对象来检索实体.对于搜索"屏幕等功能,这是一种非常方便的方法,其中在结果集上放置了可变数量的条件.

Criteria is a simplified API for retrieving entities by composing Criterion objects. This is a very convenient approach for functionality like "search" screens where there is a variable number of conditions to be placed upon the result set.

实际示例:

  1. Hibernate数据过滤器示例– XML和注释
  2. 休眠标准示例
  1. Hibernate Data Filter Example – XML And Annotation
  2. Hibernate Criteria Examples

这篇关于休眠中过滤器和条件之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆