2

我第一次尝试在休眠中调用过程,例如-

        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

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

4

1 回答 1

0

问题在于您的映射文件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>
于 2012-04-17T10:09:38.523 回答