异常**org.hibernate.QueryException: could not resolve property

异常处理

异常**org.hibernate.QueryException: could not resolve property: Name of: com.vrv.cems.log.domain.LogServerArea [ SELECT COUNT() FROM com.vrv.cems.log.domain.LogServerSoftState this WHERE this.logServer.logServerArea.Name = ?]

*.hbm.xml内容

hibernate的xml 代码块

代码块语法遵循标准markdown代码,例如:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="com.vrv.cems.log.domain">

    <class name="LogServer" table="cems_server">
        <id name="id" type="java.lang.String">
            <column name="id" />
            <generator class="assigned" />
        </id>
        <property name="name" type="string"  not-null="false" length="50"/>

        <property name="useful" type="string" not-null="false" length="50"/>

        <property name="hostname" type="string" not-null="false" length="50"/>

        <property name="description" type="string" not-null="false" length="300"/>

        <property name="ip" type="string" not-null="true" length="50"/>

        <property name="mac" type="string" not-null="false" length="512"/>

        <property name="os" type="string" not-null="false" length="30"/>

        <property name="arch" type="string" not-null="false" length="20"/>

        <property name="version" type="string" not-null="false" length="50"/>

        <property name="register" type="string" not-null="false" length="32"/>

        <property name="registTime" type="timestamp" not-null="true" />

        <property name="maintainer" type="string" not-null="false" length="15"/>

        <property name="maintainerPhone" type="string" not-null="false" length="15"/>

        <property name="maintainerTel" type="string" not-null="false" length="15"/>

        <property name="maintainerEmail" type="string" not-null="false" length="30"/>

        <property name="memorySize" type="int" not-null="false" />

        <property name="diskSize" type="int" not-null="false" />

        <property name="cpuHz" type="double" not-null="false"/>

        <property name="cpuCoreCount" type="int" not-null="false"  />

        <property name="serverAreaId" type="string" not-null="false"  length="32"/>

            <!-- 关联cems_server -->
        <many-to-one name="logServerArea" class="com.vrv.cems.log.domain.LogServerArea" column="serverAreaId" insert="false" update="false"/>
    </class>

</hibernate-mapping>
可以注意到以上的xml中有重复的属性serverAreaId和logServerArea这两个属性是一致的,this.logServer.logServerArea.Name这里无法运行说明存在矛盾的地方,解决这个问题只能去掉那个多余的属性serverAreaId,同理我这里this.logServer.logServerArea.Name是先得到logServer再得到logServerArea,同理我们也需要在logServer中取唯一的对应关系,你们也要理解hibernate框架的一些属性例如column属性和preperty-ref属性的区别
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值