is not mapped [from ***]

is not mapped [from *]

hql语句中from ….对象是实体类名称,不是数据库表名
配置文件如下:

<class name = "Stuinfo">
        <id name="stuid">
            class="native">  
        id>
        <property name="stuname"/>
        <property name="stusex"/>
        <property name="stuage"/>
        <property name="address"/>
        <property name="cid"/>
        <property name="gid"/>
        <property name="password"/>
        <property name="tele"/>
        <property name="photo"/>
class>

代码如下:

    String sql = "from Stuinfo";
    Query query = session.createQuery(sql);
    List<Stuinfo> list = query.list();

特记于此,勿忘!!!

你可能感兴趣的:(note,struts,hql,数据库)