Hi,
My organization structure is simple: one company, one root organisation and many level of organization and location under the root organization.
In my custom portlet, I needed to query the organization table to fetch the list of all my company's organizations (child and sub childs (location included) ) except the root organization. So I created this query:
I got the following stack trace
The inherent problem here is that I can't query any of Liferay entity without having the jar portal-impl.jar in either my portlet webapp or in the global class path.
Both of these solution are not recommended.
So how can I create custom queries (using finder class or DynamicQuery) to fetch data in one of Liferay's table ?
How would one go about to fetching the list of user that are associated with his Portlet's entities ? Is the best one could do is return the list of userId and then fetch them one by one ?
Is putting the portal-impl.jar file (currently found in tomcat/ROOT/WEB-INF/lib) in the global classpath a nessecary 'evil' ?
Thanks to all, any input on this would be appreciated.
cheers,
Charles
My organization structure is simple: one company, one root organisation and many level of organization and location under the root organization.
In my custom portlet, I needed to query the organization table to fetch the list of all my company's organizations (child and sub childs (location included) ) except the root organization. So I created this query:
public static List<organization> getOrganizations(boolean withLocations) {
DynamicQuery query = DynamicQueryFactoryUtil
.forClass(Organization.class)
.add(PropertyFactoryUtil.forName("companyId").eq(companyId))
.add(PropertyFactoryUtil.forName("organizationId").ne(orgId));
try {
return (List<organization>) OrganizationLocalServiceUtil
.dynamicQuery(query, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
} catch (SystemException e) {
return new ArrayList<organization>();
}
}
</organization></organization></organization>
I got the following stack trace
14:44:17,505 ERROR [DynamicQueryFactoryImpl:83] Unable find model com.liferay.portal.model.impl.OrganizationImpl
java.lang.ClassNotFoundException: com.liferay.portal.model.impl.OrganizationImpl
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
at com.liferay.portal.dao.orm.hibernate.DynamicQueryFactoryImpl.getImplClass(DynamicQueryFactoryImpl.java:78)
at com.liferay.portal.dao.orm.hibernate.DynamicQueryFactoryImpl.getImplClass(DynamicQueryFactoryImpl.java:59)
at com.liferay.portal.dao.orm.hibernate.DynamicQueryFactoryImpl.forClass(DynamicQueryFactoryImpl.java:33)
at com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil.forClass(DynamicQueryFactoryUtil.java:23)
at com.acq.portlet.common.util.AcqOrganizationUtil.getOrganizations(AcqOrganizationUtil.java:44)
at org.apache.jsp.pages.project.cp.edit.plans_005fprints_jsp._jspService(plans_005fprints_jsp.java:456)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
The inherent problem here is that I can't query any of Liferay entity without having the jar portal-impl.jar in either my portlet webapp or in the global class path.
Both of these solution are not recommended.
So how can I create custom queries (using finder class or DynamicQuery) to fetch data in one of Liferay's table ?
How would one go about to fetching the list of user that are associated with his Portlet's entities ? Is the best one could do is return the list of userId and then fetch them one by one ?
Is putting the portal-impl.jar file (currently found in tomcat/ROOT/WEB-INF/lib) in the global classpath a nessecary 'evil' ?
Thanks to all, any input on this would be appreciated.
cheers,
Charles