下面列出了org.hibernate.criterion.Example#create ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@SuppressWarnings("unchecked")
@Override
public List<T> findByExample(T exampleInstance, String... excludeProperty) {
try {
Criteria crit = getSession().createCriteria(getPersistentClass());
Example example = Example.create(exampleInstance);
for (String exclude : excludeProperty) {
example.excludeProperty(exclude);
}
crit.add(example);
return crit.list();
} catch (Exception e) {
// e.printStackTrace();
getTransaction().rollback();
return null;
}
}
@Override
@SuppressWarnings("unchecked")
public List<ISoapBoxEntity> find(ISoapBoxEntity entity) {
EntityManager manager = ConnectionDB.getManager();
manager.clear();
Session sessao = (Session) manager.getDelegate();
Example example = Example.create(entity);
example.excludeZeroes();
Criteria criteria = sessao.createCriteria(entity.getClass());
criteria.add(example);
return criteria.list();
}