首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

Hibernate 错误:org.hibernate.QueryException

2012-11-06 
Hibernate 异常:org.hibernate.QueryExceptionorg.hibernate.QueryException: could not resolve property

Hibernate 异常:org.hibernate.QueryException

org.hibernate.QueryException: could not resolve property: siteType.name of: com.dlut.domain.Site

?

public class Site implements java.io.Serializable {// Fields/** *  */private static final long serialVersionUID = 4230100379477461568L;private Long id;private SiteType siteType;        // 省略其他属性以及get,set方法}
?
<class name="com.dlut.domain.Site" table="site" schema="dbo" catalog="webdata">        <cache usage="read-only" region="DEFAULT_CACHE"/>        <id name="id" type="java.lang.Long">            <column name="id" />            <generator />        </id>        <many-to-one name="siteType" fetch="select">            <column name="type_id" />        </many-to-one></class>
?
public class SiteType implements Serializable {/** *  */private static final long serialVersionUID = -5866423360155759797L;private Integer id;private String name;private String typeDesc;      @SuppressWarnings("unchecked")private Set configGroups = new HashSet(0);        // 其它代码省略}
?
<class name="com.dlut.domain.SiteType" table="site_type" schema="dbo" catalog="webdata" lazy="false">        <cache usage="read-only" region="DEFAULT_CACHE"/>        <id name="id" type="java.lang.Integer">            <column name="id" />            <generator />        </id>        <property name="name" type="java.lang.String">            <column name="name" length="10" not-null="true" />        </property>        <property name="typeDesc" type="java.lang.String">            <column name="type_desc" length="50" not-null="true" />        </property><set name="configGroups" table="site_type_config_group" inverse="true">            <key>                <column name="site_type_id" not-null="true" />            </key>            <many-to-many column="config_group_id"></many-to-many>        </set>    </class>

?

public List<Site> getSiteBysiteTypeName(String siteTypeName) {// 设置查询条件DetachedCriteria detachedCriteria = DetachedCriteria.forClass(Site.class);detachedCriteria.add(Restrictions.eq("siteType.name", siteTypeName));return getListByCriteria(detachedCriteria);}
?

原因尚不明确,我自认为配置没有问题, 等将来想通了再补上,先作个备忘.

1 楼 xiaokk 2009-07-11   我的也一样,等你解决呢 2 楼 bcw104 2009-07-24   到现在还没解决,暂时先放弃了

热点排行