你所有的表都有相同的表结构吗?不然怎么定义Abstract类!你是想利用Java的多态特性吧!

解决方案 »

  1.   

    通过主键查询倒是可以,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,配合泛型才能实现统一查询接口。