I currently have the following named request that wraps a stored procedure: -
<hibernate-mapping>
<sql-query name="mySp">
<return-scalar column="name_first" type="string" />
<return-scalar column="name_last" type="string" />
{ call some_sp :param }
</sql-query>
</hibernate-mapping>
The name_firstand columns name_lastare the exact column names returned by the stored procedure. I created a bean that contains the same column names as I can match the result with this bean.
public class MyBean {
private String name_first;
private String name_last;
...
}
Hibernate code that calls a named query and displays the result in a bean: -
MyBean myBean = (MyBean) sessionFactory.getCurrentSession()
.getNamedQuery("mySp")
.setParameter("param", param)
.setResultTransformer(Transformers.aliasToBean(MyBean.class))
.uniqueResult();
They all work fine, but instead of relying on the column names from the stored procedure, I want to use my own column names in MyBean, for example: -
public class MyBean {
private String firstName;
private String lastName;
...
}
How do I match column names with columns of a stored procedure in my named query above?
Thank.
UPDATE. .