qq_33475696 2015-12-25 01:53 采纳率: 20%
浏览 4718

用原生sql查询 为什么实体类中存在该字段,但为什么还是报错列名无效

    这是dao层
    ds = HibernateDataSource.getHibernateDataSource();
    session = ds.getSession();
    String sql1="SELECT CHANNEL_ID FROM JC_CHANNEL WHERE PARENT_ID='"+ channelId + "'";
    SQLQuery sqlQuery1 = session.createSQLQuery(sql1.toString());
    List<Channel> channelList = sqlQuery1.addScalar("id",Hibernate.INTEGER).setResultTransformer(Transformers.aliasToBean(Channel.class)).list();
    List idList=new ArrayList();
    这是配置文件中
    <class name="Channel" table="jc_channel" dynamic-update="true">
    <meta attribute="sync-DAO">false</meta>
    <cache usage="read-write"/>
    <id name="id" type="java.lang.Integer" column="channel_id">
        <!-- <generator class="identity"/>-->
        <generator class="sequence">
            <param name="sequence">SEQ_JC_CHANNEL</param>
        </generator>
    </id>
    <property name="path" column="channel_path" type="string" not-null="false" length="30"/>
    <property name="lft" column="lft" type="integer" not-null="true" length="10"/>
    <property name="rgt" column="rgt" type="integer" not-null="true" length="10"/>
    <property name="priority" column="priority" type="integer" not-null="true" length="10"/>
    <property name="hasContent" column="has_content" type="java.lang.Boolean" not-null="true"/>
    <property name="display" column="is_display" type="java.lang.Boolean" not-null="true"/>
    <one-to-one name="channelExt" class="ChannelExt" cascade="delete"/>
    <many-to-one name="site" column="site_id" class="CmsSite" not-null="true"></many-to-one>
    <many-to-one name="model" column="model_id" class="CmsModel" not-null="true"></many-to-one>
    <many-to-one name="parent" column="parent_id" class="Channel" not-null="false"></many-to-one>
    <set name="child" inverse="true" cascade="delete" sort="com.jeecms.common.hibernate3.PriorityComparator">
        <cache usage="read-write"/>
        <key column="parent_id"/>
        <one-to-many class="Channel"/>
    </set>
    <set name="viewGroups" table="jc_chnl_group_view" sort="com.jeecms.common.hibernate3.PriorityComparator">
        <cache usage="read-write"/>
        <key column="channel_id"/>
        <many-to-many column="group_id" class="CmsGroup"/>
    </set>
    <set name="contriGroups" table="jc_chnl_group_contri" sort="com.jeecms.common.hibernate3.PriorityComparator">
        <cache usage="read-write"/>
        <key column="channel_id"/>
        <many-to-many column="group_id" class="CmsGroup"/>
    </set>
    <set name="users" table="jc_channel_user" sort="com.jeecms.common.hibernate3.PriorityComparator">
        <cache usage="read-write"/>
        <key column="channel_id"/>
        <many-to-many column="user_id" class="CmsUser"/>
    </set>
    <set name="channelTxtSet" inverse="true" cascade="delete-orphan">
        <cache usage="read-write"/>
        <key column="channel_id"/>
        <one-to-many class="ChannelTxt"/>
    </set>
    <map name="attr" table="jc_channel_attr" cascade="all-delete-orphan">
        <cache usage="read-write"/>
        <key column="channel_id" not-null="true"/>
        <map-key column="attr_name" type="string" length="30"/>
        <element column="attr_value" type="string" length="255"/>
    </map>
</class>

  • 写回答

4条回答 默认 最新

  • 思想在飞肢体在追 2015-12-25 02:06
    关注

    把数据库表名换成是对象(类名)试试看

    评论

报告相同问题?

悬赏问题

  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集