Reputation: 73
I am using jsp and hibernate. Below is my function -
public static List<user_detail> getData(String username)
{
List<user_detail> list = null;
try{
Session session=newConfiguration().configure().buildSessionFactory().openSession();
Transaction tx=session.beginTransaction();
Query query = session.createQuery("from user_detail where username = :user");
query.setParameter("user", username);
list = query.list();
Iterator<user_detail> itr=list.iterator();
while(itr.hasNext()){
descLog("Parameters"+itr.next()+"\n");
}
}
catch(Exception e)
{
writeLog(e);
}
return list;
}
I call this function from my jsp page. But the problem is every time this function takes around 5 second. I have only one record in table. Why this is taking time ? How to reduce this time ?
Upvotes: 0
Views: 116
Reputation: 692201
There are many things wrong in the above code:
UserDetail
, not user_detail
. I suggest you re-read the Hibernate reference documentation from scratch.
Upvotes: 2