How to fetch selected columns at run time using SQL Native Query in Hibernate?


hinernate_logo

In following example , I am selecting  two columns  passing columns name at run time (by passing parameter in getAllGraphData method).
public List getAllGraphData(int loginId, String bodyStats, String fixedDatePeriod) {
List list = null;
session = HibernateUtil.getSession();
transaction = session.beginTransaction();
list = session.createSQLQuery("select * from user_stats where loginId=:LoginId")
.addScalar(fixedDatePeriod)
.addScalar(bodyStats)
.setInteger("LoginId", loginId).list();
}

Share on Google Plus

About JK STACK

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment