Hibernate提供了外置命名查詢方式
我的代碼
[html]
<class name=
<id name=
<generator class=
</id>
<property name=
<many
<query name=
<![CDATA[
select s from Student s where s
]]>
</query>
</class>
<class name=
<id name=
<generator class=
</id>
<property name=
<many
<query name=
<![CDATA[
select s from Student s where s
]]>
</query>
</class>
結果在java測試類中執行
[java]
List list = session
List list = session
出現報錯
[html]
org
at org
……
org
at org
……
程序沒有找到這個命名查詢語句
在映射文件中配置<query>時
改成
[html]
SPAN > <class name=
<id name=
<generator class=
</id>
<property name=
<many
</class>
<query name=
<![CDATA[
select s from Student s where s
]]>
</query></SPAN>
<class name=
<id name=
<generator class=
</id>
<property name=
<many
</class>
<query name=
<![CDATA[
select s from Student s where s
]]>
</query>
From:http://tw.wingwit.com/Article/program/Java/ky/201311/28671.html