HIbernate的数据库操作用法

select name,sex from db 这个SQL语句使用HIbernate的中的哪个方法比较合适,例如:
public T findByID(ID id, I dbName) throws Exception;

public List<T> findAll(I dbName) throws Exception;

public List<T> findByExample(T exampleInstance, I dbName,
        String... excludeProperties) throws Exception;

public List<T> findByExample(T exampleInstance, I dbName) throws Exception;

public List<T> findByCriteria(I dbName, Criterion... criterions) throws Exception;

public List<T> findByCriteria(I dbName, List<Criterion> criterions) throws Exception;

public List<T> findByCriteria(I dbName, List<Criterion> criterions,
        List<Order> orders) throws Exception;

public List<T> findByCriteriaAndLimtSize(I dbName, int size,
        Criterion... criterions) throws Exception;

public List<T> findByCriteriaByPage(I dbName, int offsetFrom, int size,
        List<Criterion> criterions, List<Order> orders) throws Exception;
阅读 1.6k
1 个回答

hibernate的查询是用query对象来进行的,即Query query=session.createQuery(sql),在对query遍历或者直接转list就行。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题