如何按组名查找com.liferay.portal.model.Group
个对象?另外如何按角色名称查找com.liferay.portal.model.Role
?
============= EDIT ===============
我有testGroup
:
Group group = GroupServiceUtil.getGroup(themeDisplay.getCompanyId(), "testGroup");
结果:
11:09:09,858 ERROR [RuntimePageImpl-15][render_portlet_jsp:132] null
com.liferay.portal.NoSuchGroupException: No Group exists with the key {companyId=10157, name=testGroup}
at com.liferay.portal.service.persistence.GroupPersistenceImpl.findByC_N(GroupPersistenceImpl.java:3253)
at com.liferay.portal.service.impl.GroupLocalServiceImpl.loadGetGroup(GroupLocalServiceImpl.java:2054)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:115)
at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:62)
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:51)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:175)
at com.liferay.portal.service.impl.GroupLocalServiceImpl.getGroup(GroupLocalServiceImpl.java:1196)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:115)
at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:175)
at com.liferay.portal.service.impl.GroupServiceImpl.getGroup(GroupServiceImpl.java:329)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:115)
at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:62)
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:51)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:175)
答案 0 :(得分:3)
您可以使用以下API方法按名称查找组和角色:
GroupLocalServiceUtil.getGroup(long companyId, java.lang.String name)
RoleLocalServiceUtil.getRole(long companyId, java.lang.String name)