通过主键查询倒是可以,hibernate提供接口了/** * Return the persistent instance of the given entity class with the given identifier, * or null if there is no such persistent instance. (If the instance is already associated * with the session, return that instance. This method never returns an uninitialized instance.) * * @param clazz a persistent class * @param id an identifier * * @return a persistent instance or null */ public Object get(Class clazz, Serializable id); 如果是要查询表的所有数据,必需写sql,配合泛型才能实现统一查询接口。
* Return the persistent instance of the given entity class with the given identifier,
* or null if there is no such persistent instance. (If the instance is already associated
* with the session, return that instance. This method never returns an uninitialized instance.)
*
* @param clazz a persistent class
* @param id an identifier
*
* @return a persistent instance or null
*/
public Object get(Class clazz, Serializable id);
如果是要查询表的所有数据,必需写sql,配合泛型才能实现统一查询接口。