Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Kiran Kumar Boyini
How to get the List object of entity in our actionclass or jsp page
November 29, 2012 2:14 AM
Answer

Kiran Kumar Boyini

Rank: Expert

Posts: 286

Join Date: June 2, 2011

Recent Posts

Hi All,

I have run the service file for entity employee. Now I want to get the list of records records available from the database in conntroller and jsp

page. I have observerd two classes are there to get the list of records.

1) EmployeeUtil.findAll() method.But here in comments of this class definition, Never access this utility in a JSP, controller, model, or other front-end class.

Still i used this method and I have got the following exception as follows

ERROR [BasePersistenceImpl:188] Caught unexpected exception org.hibernate.HibernateException
####################com.liferay.portal.kernel.exception.SystemException: org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here

2) java.util.List<com.vam.model.Employee> empList=new EmployeePersistenceImpl().findAll();

I have used the above method,but I am getting exception ERROR [BasePersistenceImpl:188] Caught unexpected exception java.lang.NullPointerException
####################java.lang.NullPointerException


Please reply me is there any settings required or is there any alternative to get the list.

Thanks
Kiiran
Siby Mathew
RE: How to get the List object of entity in our actionclass or jsp page
November 29, 2012 6:08 AM
Answer

Siby Mathew

Rank: Expert

Posts: 267

Join Date: March 4, 2011

Recent Posts

Hi Kiran,
If you are trying to fetch it from your DB, then you have to use the EmployeeLocalServiceUtil.getEmployees(start,end)
Never instantiate and directly reference the persistence classes.

Thanks,
Siby
Kiran Kumar Boyini
RE: How to get the List object of entity in our actionclass or jsp page
November 30, 2012 1:17 AM
Answer

Kiran Kumar Boyini

Rank: Expert

Posts: 286

Join Date: June 2, 2011

Recent Posts

Thank you, it is working