开发者

Why this hibernate exception occurs,,,

开发者 https://www.devze.com 2023-02-19 04:28 出处:网络
I\'m getting the exception like, \"Named Query mySp Not known\" The mapping file will be looking like this,

I'm getting the exception like, "Named Query mySp Not known"

The mapping file will be looking like this,

<hibernate-mapping>
    <sql-query name="mySp">
        <return-scalar column="count1" type="int" />
        <return-scalar column="name" type="int" />
        <return-scalar column="count2" type="int" />
        { call get_proc_sp :p1,p2,p3 }
    </sql-query>
</hibernate-mapping>

My Procedure name is, get_proc_sp and it accepts three parameters, the parameter names are m1,m2,m3

This is the DAO code,

List<MyBean> list = sessionFactory.getCurrentSession()
    .getNamedQuery("mySp")
    .setParameter("m1", arg1)
    .setParameter("m2", narg)
    .setParameter("m3", arg5)
    .setResultTransformer(Transformers.ali开发者_如何学编程asToBean(MyBean.class))
    .list();


One likely reason is that the hbm file in which you are defining the query is not registered with the sessionFactory.

0

精彩评论

暂无评论...
验证码 换一张
取 消