• Post Reply Bookmark Topic Watch Topic
  • New Topic

Issue in using generics  RSS feed

 
yog gaikwad
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have following method in class
public class QueryDAOImp {
public <T> List<T> viewByCompId() {
Session session1 =hibernateUtil.getSessionFactory().openSession();
session1.beginTransaction();
Query q = (Query) session1.createQuery("from CompanyEntryBean" );
List<T> user1 = (List<T>) q.list();
session1.beginTransaction().commit();
session1.flush();
session1.close();

return user1;
}}

and i am calling it from jsp like this.
QueryDAOImp qd = new QueryDAOImp();
List<CompanyEntryBean> cmpBean = qd.viewByCompId();
for (CompanyEntryBean ud : cmpBean) {
id = ud.getCompany_Id();
System.out.println("done id" + id);
}

it works some times and some times it doesn't work please give me solution
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to tell us what happens when it doesn't work.

By not working, what exactly do you mean? Do you receive an exception? Does the query not return a result when you expect it to?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!