CreateSqlQuery()/CreateQuery()/返回Map结果集相关方法列举

Query query = this.getSession().createSQLQuery(sql).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);

query.setFirstResult(pageIndex);

query.setMaxResults(pageSize);

query.setParameter(i, p.get(i));

List list = query.list();

Object object = queryCount.uniqueResult(); //只能返回一个结果

int i = query.executeUpdate();


getSession().get(entityClass, id);

Serializable id = getSession().save(entity);

getSession().update(entity);

getSession().delete(entity);//有id值

getSession().clear();

getSession().evict(entity);


Query query = getSession().createQuery(sb.toString());

query.setFirstResult((currentPage - 1) * pageSize);

query.setMaxResults(pageSize);

query.setParameter(name.replace(".", ""), value);

query.setParameter(a, list.get(a));

List list = query.list();

Object object = queryCount.uniqueResult(); //只能返回一个结果

int i = query.executeUpdate();




你可能感兴趣的:(Hibernate)