How can I use @NamedNativeQuery to call stored procedure without Entity

40 views Asked by At

I have hibernate3.6 in project, and need to call stored procedure with 3 input and 2 output params, as i found - its better to use @NamedNativeQuery, i try to use examples - but it still doesnt work

On my project is still hibernate3.6 without Spring. I have just a stored procedure to use like

CREATE OR REPLACE PROCEDURE CHECK_KEY(
    p_name            in  varchar2
    ,p_key            in  varchar2
    ,p_sys_reg_num    in  varchar2
    ,p_success        out number
    ,p_err            out varchar2   
) 

so I need to call it and get result like pojo(boolean, String).

@SqlResultSetMapping(name="ClientCheck.Mapping", entities = {
  @EntityResult(entityClass=ClientCheck.class, fields = {
    @FieldResult(name="pSuccess", column="p_Success"),
    @FieldResult(name="pError", column="p_Error")
  })
})
@NamedNativeQueries({
  @NamedNativeQuery(
    name = "checkKey",
    query = "CALL check_key(:clientName, :clientKey, :systemRegNumber)",
    resultSetMapping = "ClientCheck.Mapping")
})
public class ClientCheck implements Serializable {
  boolean pSuccess;
  String pError;

}

but when i try session.getNamedQuery("checkKey"); i got like Method threw 'org.hibernate.MappingException' exception. Named query not known: checkKey

So hibernate doesnt know about it. How can i fix this? I try use @Entity only, and with <mapping class /> in hibernate.cfg.xml, but no positive results

0

There are 0 answers