Forums

Home » Liferay Portal » English » 2. Using Liferay » General

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Jay Trivedi
Dynamic Query Problem
December 18, 2012 2:37 AM
Answer

Jay Trivedi

Rank: Regular Member

Posts: 107

Join Date: November 23, 2012

Recent Posts

Hey friends I execute following code but it gives me error. i am not able to find the root cause.
Any Suggestions

 1
 2try {
 3      DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(UserGroup.class);
 4   
 5    dynamicQuery.add(PropertyFactoryUtil.forName("parentUserGroupId").eq(20209));//(GroupLocalServiceUtil.getGroup(themeDisplay.getCompanyId(), companyGetDetails.getCompanySite()).getGroupId() ));
 6   
 7    List<UserGroup> results1 = new ArrayList<UserGroup>();
 8    //Collections.<ShoppingItem> emptyList();
 9    //List<UserGroup> results2 = new ArrayList<UserGroup>();
10    results1=UserGroupLocalServiceUtil.dynamicQuery(dynamicQuery);
11    out.println("VVVVVVVVVVVVVVVVVVV>>>>>>>>>>>>>>>>>>>>>>"+results1);
12    }catch(Exception e) {e.printStackTrace();}
13   
1410:32:23,581 ERROR [DynamicQueryFactoryImpl:83] Unable find model com.liferay.portal.model.impl.UserGroupImpl
15java.lang.ClassNotFoundException: com.liferay.portal.model.impl.UserGroupImpl
16    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1688)
17    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1533)
18    at com.liferay.portal.dao.orm.hibernate.DynamicQueryFactoryImpl.getImplClass(DynamicQueryFactoryImpl.java:78)
19    at com.liferay.portal.dao.orm.hibernate.DynamicQueryFactoryImpl.getImplClass(DynamicQueryFactoryImpl.java:59)
20    at com.liferay.portal.dao.orm.hibernate.DynamicQueryFactoryImpl.forClass(DynamicQueryFactoryImpl.java:33)
21    at com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil.forClass(DynamicQueryFactoryUtil.java:23)
22    at org.apache.jsp.html.ba_005fcompanytab.view_jsp._jspService(view_jsp.java:5141)
23    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
24    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
25    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
26    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
27    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
28    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
29    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
30    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
31    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
32    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:113)
33    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:70)
34    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
35    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
36    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
37    at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:593)
38    at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:530)
39    at com.liferay.portlet.PortletRequestDispatcherImpl.dispatch(PortletRequestDispatcherImpl.java:316)
40    at com.liferay.portlet.PortletRequestDispatcherImpl.include(PortletRequestDispatcherImpl.java:134)
41    at com.ba.portlets.ba_companytabs.CompanyTabPortlet.doView(CompanyTabPortlet.java:295)
42    at javax.portlet.GenericPortlet.doDispatch(GenericPortlet.java:328)
43    at javax.portlet.GenericPortlet.render(GenericPortlet.java:233)
44    at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:100)
45    at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:64)


Help me out,
Thanks Jay.
Rewati Raman
RE: Dynamic Query Problem
December 18, 2012 3:45 AM
Answer

Rewati Raman

Rank: Junior Member

Posts: 97

Join Date: February 24, 2012

Recent Posts

Hi Jay,
as i understood you need to modify

1DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(UserGroup.class);


with

1DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(UserGroup.class, PortalClassLoaderUtil.getClassLoader());


https://www.liferay.com/community/forums/-/message_boards/message/7855950
this link might help you as the problem is resolved in this link..

Regards,
Rewati Raman
Jay Trivedi
RE: Dynamic Query Problem
December 18, 2012 6:34 AM
Answer

Jay Trivedi

Rank: Regular Member

Posts: 107

Join Date: November 23, 2012

Recent Posts

It worked

 1
 2
 3try {
 4      DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(UserGroup.class,PortalClassLoaderUtil.getClassLoader());
 5   
 6    dynamicQuery.add(PropertyFactoryUtil.forName("parentUserGroupId").eq(20209));//(GroupLocalServiceUtil.getGroup(themeDisplay.getCompanyId(), companyGetDetails.getCompanySite()).getGroupId() ));
 7   
 8    List<UserGroup> results1 = new ArrayList<UserGroup>();
 9    results1=UserGroupLocalServiceUtil.dynamicQuery(dynamicQuery);
10    }catch(Exception e) {e.printStackTrace();}
11   

is Perfect!!

Thanks a Lot 'Rewati Raman'

Regards,
Jay