Link to home
Start Free TrialLog in
Avatar of Sachin_Ajmani
Sachin_AjmaniFlag for India

asked on

how to call stored procure using hibernate

Procedure name:xydata_gespeed
 
BEGIN
    SELECT * FROM xydata xy
   WHERE xy.ObjectId = xy_objectId
  AND xy.ClientId=xy_clientId
  AND xy.GpsTime >= xy_gpstime
  AND xy.GpsTime <= xy_gpstime1
  AND xy.Speed >= xy_speed ORDER BY xy.GpsTime ASC;
END

Open in new window

In Entity class
 
@Entity
@NamedNativeQuery(name = "xydatas",
resultClass = Xydata.class,
query = "{call xydata_gespeed(:objectId,:clientId,:gpsTime,:gpsTime,:speed)}",
hints = {
    @QueryHint(name = "org.hibernate.callable", value = "true")
})

Open in new window


In hibernate query

 
List list1 = getSession().getNamedQuery("xydatas").setParameter("objectId", Objectid).setParameter("clientId", Integer.valueOf(id)).setParameter("gpsTime", from).setParameter("gpsTime", to).setParameter("speed", Integer.valueOf(speed)).list();

            System.out.println("Listttt " + list1.size());

Open in new window


i am getting System.out.println("Listttt " + list1.size());

list size zero what i am doing wrong please help me
ASKER CERTIFIED SOLUTION
Avatar of Sathish David  Kumar N
Sathish David Kumar N
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial