Pages

Saturday 13 October 2012

How to fetch Liferay's entity using DynamicQuery or Finder class

How to fetch Liferay's entity using DynamicQuery or Finder class
How to fetch Liferay's entity using DynamicQuery?


I was using the DynamicQuery but getting the error "Unable" to find model class.

was trying to find the issue and I got the solution for the same.

I am sharing the solution with you Guys,

To allow your DynamicQuery to access the implementation class:

Below are the three different scenario to access the implementation class.

1) If your implementation class is in your portlet.

Ans: You don't need to use special classloader. It's will work out of the box. 

2) If the implementation class is the part of the portal .

Ans: Use the below line:
       
Classloader loader = PortalClassLoaderUtil.getClassLoader();

3) If the implementation class is in another portlet.

Ans: Use the below line:
        
ClassLoader classLoader = (ClassLoader)PortletBeanLocatorUtil.locate(ClpSerializer.SERVLET_CONTEXT_NAME,"portletClassLoader");

 Hope it helps! :)

No comments:

Post a Comment