안녕하세요. 쿼리를 수행하는 데 작은 문제가 있습니다. 쿼리 라인은 입니다. Query query = session.createQuery ("Recipe r from r.name = '"+ searchString + "' r.ownerid = "+ userId);Hibernate 질의 - 프로퍼티 해결과 관련된 문제
.hbm.xml 파일은 다음과 같습니다
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Aug 26, 2011 10:56:44 AM by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>
<class catalog="icdb" name="com.icdb.data.Recipe" table="recipes">
<id name="recipeid" type="int">
<column name="recipeid"/>
<generator class="identity"/>
</id>
<many-to-one class="com.icdb.data.User" fetch="select" name="users">
<column name="ownerid" not-null="true"/>
</many-to-one>
<property generated="never" lazy="false" name="releasedate" type="timestamp">
<column length="19" name="releasedate" not-null="true"/>
</property>
<property generated="never" lazy="false" name="preparationtime" type="int">
<column name="preparationtime" not-null="true"/>
</property>
<property generated="never" lazy="false" name="name" type="string">
<column length="50" name="name" not-null="true"/>
</property>
<property generated="never" lazy="false" name="description" type="string">
<column length="200" name="description"/>
</property>
<property generated="never" lazy="false" name="lastupdated" type="timestamp">
<column length="19" name="lastupdated" not-null="true"/>
</property>
<property generated="never" lazy="false" name="servecount" type="java.lang.Integer">
<column name="servecount"/>
</property>
<property generated="never" lazy="false" name="complete" type="boolean">
<column name="complete" not-null="true"/>
</property>
<set fetch="select" inverse="true" lazy="true" name="recipepictureses"
sort="unsorted" table="recipepictures">
<key>
<column name="recipeid" not-null="true"/>
</key>
<one-to-many class="com.icdb.data.RecipePicture"/>
</set>
<set fetch="select" inverse="true" lazy="true"
name="recipeingredientses" sort="unsorted" table="recipeingredients">
<key>
<column name="recipeid" not-null="true"/>
</key>
<one-to-many class="com.icdb.data.RecipeIngredient"/>
</set>
<set fetch="select" inverse="true" lazy="true" name="recipetipses"
sort="unsorted" table="recipetips">
<key>
<column name="recipeid" not-null="true"/>
</key>
<one-to-many class="com.icdb.data.RecipeTip"/>
</set>
<set fetch="select" inverse="true" lazy="true" name="recipereviewses"
sort="unsorted" table="recipereviews">
<key>
<column name="recipeid" not-null="true"/>
</key>
<one-to-many class="com.icdb.data.RecipeReview"/>
</set>
<set fetch="select" inverse="true" lazy="true"
name="recipeinstructionses" sort="unsorted" table="recipeinstructions">
<key>
<column name="recipeid" not-null="true"/>
</key>
<one-to-many class="com.icdb.data.RecipeInstruction"/>
</set>
<property name="recipedifficulty" type="int">
<column name="recipedifficulty" not-null="true" sql-type="INTEGER"/>
</property>
</class>
</hibernate-mapping>
내가 예외가 - 말하는 "레시피 ownerid 속성을 확인할 수 없습니다 ..."
이유는 무엇입니까? 내가 잘못 선언 한 것은 무엇입니까? 아니면 잘못된 방식으로 쿼리를 수행합니까?
1) (
<property name="ownerid" type="int">
<column name="ownerid" not-null="true"/>
</property>
또는
2
가) 쿼리에 r.users.id을 사용하는 매핑 ownerid 속성을 추가 :아브