T - 实体类型ID - 主键类型public class HibernateDAO<T,ID extends Serializable> extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
protected org.slf4j.Logger |
logger |
| 构造器和说明 |
|---|
HibernateDAO()
通过子类的泛型定义取得实体类型。
|
HibernateDAO(Class<T> entityClass)
直接指定实体类型。
|
HibernateDAO(org.hibernate.SessionFactory sessionFactory)
通过子类的泛型定义取得实体类型。
|
HibernateDAO(org.hibernate.SessionFactory sessionFactory,
Class<T> entityClass)
直接指定实体类型。
|
| 限定符和类型 | 方法和说明 |
|---|---|
int |
batchExecute(String hql,
Map<String,?> param)
执行HQL进行批量修改/删除操作.
|
int |
batchExecute(String hql,
Object... param)
执行HQL进行批量修改/删除操作.
|
long |
count() |
long |
count(String hql,
Map<String,?> param) |
org.hibernate.Criteria |
createCriteria(org.hibernate.criterion.Criterion... criterions)
根据 Criterion 条件创建 Criteria。
|
org.hibernate.Query |
createQuery(String hql,
Map<String,?> param)
根据查询HQL与参数列表创建Query对象.
|
org.hibernate.Query |
createQuery(String hql,
Map<String,?> param,
org.springframework.data.domain.Pageable pageable)
根据查询 HQL 与参数列表创建 Query 对象。
|
org.hibernate.Query |
createQuery(String hql,
Object... param)
根据查询HQL与参数列表创建Query对象.
|
org.hibernate.Session |
currentSession()
取得当前 Session。
|
void |
delete(ID id)
按 id 删除对象。
|
void |
delete(Iterable<? extends T> entities) |
void |
delete(T entity)
删除对象。
|
void |
deleteAll() |
void |
distinct(org.hibernate.Criteria criteria)
为 Criteria 添加 distinct transformer。
|
void |
distinct(org.hibernate.Query query)
为 Query 添加 distinct transformer。
|
boolean |
exists(ID id) |
List<T> |
find(org.hibernate.criterion.Criterion... criterions)
按 Criteria 查询对象列表。
|
List<T> |
find(String hql,
Map<String,?> param)
按HQL查询对象列表.
|
org.springframework.data.domain.Page<T> |
find(String hql,
Map<String,?> param,
org.springframework.data.domain.Pageable pageable) |
List<T> |
find(String hql,
Object... param)
按HQL查询对象列表.
|
Iterable<T> |
findAll()
获取全部对象。
|
Iterable<T> |
findAll(Iterable<ID> ids)
按 id 列表获取对象列表。
|
org.springframework.data.domain.Page<T> |
findAll(org.springframework.data.domain.Pageable pageable) |
Iterable<T> |
findAll(org.springframework.data.domain.Sort sort)
获取全部对象,支持按属性行序。
|
List<T> |
findBy(String propertyName,
Object value)
按属性查找对象列表,匹配方式为相等。
|
T |
findOne(org.hibernate.criterion.Criterion... criterions)
按 Criteria 查询唯一对象。
|
T |
findOne(ID id)
按 id 获取对象。
|
T |
findOneBy(String propertyName,
Object value)
按属性查找唯一对象,匹配方式为相等。
|
T |
findUnique(String hql,
Map<String,?> param)
按HQL查询唯一对象.
|
T |
findUnique(String hql,
Object... param)
按HQL查询唯一对象.
|
Class<T> |
getEntityClass() |
org.hibernate.SessionFactory |
getSessionFactory()
取得 sessionFactory。
|
boolean |
isAutoFlush() |
boolean |
isPropertyUnique(String propertyName,
Object newValue,
Object oldValue)
判断对象的属性值在数据库内是否唯一。
|
<S extends T> |
save(Iterable<S> entities) |
<S extends T> |
save(S entity)
保存新增或修改的对象。
|
void |
setSessionFactory(org.hibernate.SessionFactory sessionFactory) |
void |
update(T entity) |
public HibernateDAO()
public HibernateDAO(org.hibernate.SessionFactory sessionFactory)
public org.hibernate.SessionFactory getSessionFactory()
public void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
public org.hibernate.Session currentSession()
public boolean isAutoFlush()
public <S extends T> S save(S entity)
public boolean exists(ID id)
public long count()
public void delete(ID id)
public void delete(T entity)
entity - 对象必须是 session 中的对象或含 id 属性的 transient 对象public void deleteAll()
public org.springframework.data.domain.Page<T> findAll(org.springframework.data.domain.Pageable pageable)
public void update(T entity)
public List<T> find(org.hibernate.criterion.Criterion... criterions)
criterions - 数量可变的 Criterionpublic T findOne(org.hibernate.criterion.Criterion... criterions)
criterions - 数量可变的 Criterionpublic boolean isPropertyUnique(String propertyName, Object newValue, Object oldValue)
public org.hibernate.Criteria createCriteria(org.hibernate.criterion.Criterion... criterions)
criterions - 数量可变的 Criterionpublic org.springframework.data.domain.Page<T> find(String hql, Map<String,?> param, org.springframework.data.domain.Pageable pageable)
public int batchExecute(String hql, Object... param)
param - 数量可变的参数,按顺序绑定.public int batchExecute(String hql, Map<String,?> param)
param - 命名参数,按名称绑定.public org.hibernate.Query createQuery(String hql, Object... param)
param - 数量可变的参数,按顺序绑定.public org.hibernate.Query createQuery(String hql, Map<String,?> param)
param - 命名参数,按名称绑定.public org.hibernate.Query createQuery(String hql, Map<String,?> param, org.springframework.data.domain.Pageable pageable)
hql - HQLparam - 参数pageable - 分页参数public void distinct(org.hibernate.Criteria criteria)
public void distinct(org.hibernate.Query query)
Copyright © 2008–2014 Matrix. All rights reserved.