鍍金池/ 問答/Java  數(shù)據(jù)庫  HTML/ HIbernate的數(shù)據(jù)庫操作用法

HIbernate的數(shù)據(jù)庫操作用法

select name,sex from db 這個(gè)SQL語句使用HIbernate的中的哪個(gè)方法比較合適,例如:
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;
回答
編輯回答
澐染

hibernate的查詢是用query對(duì)象來進(jìn)行的,即Query query=session.createQuery(sql),在對(duì)query遍歷或者直接轉(zhuǎn)list就行。

2017年9月23日 01:43