gpt4 book ai didi

java - 如何在 hibernate 中调用程序?

转载 作者:行者123 更新时间:2023-11-29 09:14:44 26 4
gpt4 key购买 nike

我第一次尝试在 hibernate 状态下调用过程 -

        Session session = HibernateUtil.getFirstFactory().getCurrentSession();
session.beginTransaction();
Query q = getSession().getNamedQuery("select");
q.setInteger("locationid", locId);
cDbInsts = (List<SpCustsitesettings>) q.list();

我的 hbm 文件 SpCustsitesettings.hbm.xml 是 -

<hibernate-mapping>
<class name="glb.chatmeter.db.SpCustsitesettings">
<id name="cmcustLocId" type="int">
<column name="CMCustLocID"/>
</id>
<property name="cpid" type="string">
<column name="CPID">
</column>
</property>
</class>
<sql-query name="select" callable="true">
<return alias="select" class="glb.chatmeter.db.SpCustsitesettings">
<return-property name="cmcustLocId" column="CMCustLocID" />
<return-property name="cpid" column="CPID" />
</return>
<query-param name="locationid" type="int" />
{call select(:locationid)}
</sql-query>

我已经在配置文件中添加了它,比如 -

<mapping resource="xml/SpCustsitesettings.hbm.xml"/>

但是当我去执行我的查询时显示异常 -

java.lang.StackOverflowError
at gnu.xml.pipeline.ValidationConsumer$ChildrenRecognizer.patchNext(ValidationConsumer.java:1570)
at gnu.xml.pipeline.ValidationConsumer$ChildrenRecognizer.patchNext(ValidationConsumer.java:1591)
at gnu.xml.pipeline.ValidationConsumer$ChildrenRecognizer.patchNext(ValidationConsumer.java:1580)
at gnu.xml.pipeline.ValidationConsumer$ChildrenRecognizer.patchNext(ValidationConsumer.java:1580)
at gnu.xml.pipeline.ValidationConsumer$ChildrenRecognizer.patchNext(ValidationConsumer.java:1591)
.............................................................................

程序将关闭。这是我的程序-

 CREATE DEFINER=`root`@`%` PROCEDURE `select`(IN locationid INT)
BEGIN
SELECT cmcustLocId, cpid FROM `custsitesettings` WHERE `CMCustLocID` = locationid;
END

我没有解决的问题是什么,任何人都可以帮助我。

最佳答案

问题出在您的映射文件 SpCustsitesettings.hbm.xml 中。

改变

<hibernate-mapping>
.....

<sql-query name="select" callable="true">
<return alias="select" class="glb.chatmeter.db.SpCustsitesettings">
<return-property name="cmcustLocId" column="CMCustLocID" />
<return-property name="cpid" column="CPID" />
</return>
<query-param name="locationid" type="int" />
{call select(:locationid)}
</sql-query>
</hibernate-mapping>

<sql-query name="select" callable="true">
<return alias="select" class="glb.chatmeter.db.SpCustsitesettings">
<return-property name="cmcustLocId" column="CMCustLocID" />
<return-property name="cpid" column="CPID" />
</return>
<query-param name="locationid" type="int" />
<![CDATA[CALL select(:locationid)]]>
</sql-query>

关于java - 如何在 hibernate 中调用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10188873/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com