留言板

Facing a problem with findByXXX() methods in liferay plugins

thumbnail
guru murthy,修改在12 年前。

Facing a problem with findByXXX() methods in liferay plugins

Regular Member 帖子: 208 加入日期: 11-8-12 最近的帖子
Hi All ,

Right now I am working with liferay V5.1.2 . The database is MySQL , OS is ubuntu .

I am able to create a finder methods using service builder ( service.xml ) in plugins portlets but when i use those finder methods in JSP's like [Entity]Util.findByXXX(value) then i get the below exception .

javax.servlet.ServletException: com.liferay.portal.SystemException: java.lang.IllegalArgumentException: No positional parameters in query: FROM package.Entity WHERE groupId = ?


I get the above only when i use finder methods . If anybody know the answer for this please share it .

Not only for finder methods , it's showing error for countXXX() methods also.
Caught unexpected exception java.lang.IllegalArgumentException
com.liferay.portal.SystemException: java.lang.IllegalArgumentException: No positional parameters in query: SELECT COUNT(*) FROM package.Entity WHERE Name = ?


Thanks in advance .
G.Gurumurthy
thumbnail
David H Nebinger,修改在12 年前。

RE: Facing a problem with findByXXX() methods in liferay plugins

Liferay Legend 帖子: 14916 加入日期: 06-9-2 最近的帖子
It means you're not passing the argument to the finder to call it correctly (or possibly passing a null).

Try passing real arguments to the finder methods.
thumbnail
Hitoshi Ozawa,修改在12 年前。

RE: Facing a problem with findByXXX() methods in liferay plugins

Liferay Legend 帖子: 7942 加入日期: 10-3-24 最近的帖子
As David said, you're probably not passing the right parameters. If you need further assistance, you'll probably have to paste your code so we'll be able to look at it.
thumbnail
David H Nebinger,修改在12 年前。

RE: Facing a problem with findByXXX() methods in liferay plugins

Liferay Legend 帖子: 14916 加入日期: 06-9-2 最近的帖子
Jeez, Hitoshi, how can I ever catch up to your post count if you keep replying to my posts emoticon
thumbnail
guru murthy,修改在12 年前。

RE: Facing a problem with findByXXX() methods in liferay plugins

Regular Member 帖子: 208 加入日期: 11-8-12 最近的帖子
Hi ,

As you said , I am sending the code related to my work , please go through it .
This is my service.xml in plugins V5.1.2

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 5.1.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_5_1_0.dtd">

<service-builder package-path="com.roles" >

<namespace>Group</namespace>

<entity name="Roles" local-service="true" remote-service="false" >
<!-- PK fields -->
<column name="roleId" type="Integer" primary="true" id-type="increment" />

<!-- Normal columns -->
<column name="Name" type="String" />
<column name="ParentRoleId" type="Integer" />
<column name="groupId" type="Long" />
<column name="RoleType" type="Integer" />
<column name="Description" type="String" />

<finder name="RoleName" return-type="Roles">
<finder-column name="Name" />
</finder>
<finder name="Group" return-type="Collection">
<finder-column name="groupId" />
</finder>
<finder return-type="Collection" name="ParentRoleId">
<finder-column name="ParentRoleId" />
</finder>

</entity>

<entity name="Roles_Types" local-service="true" remote-service="false">
<!-- PK fields -->
<column name="Id" type="Integer" primary="true" id-type="increment"/>
<!-- Normal columns -->
<column name="RoleType" type="String"/>
<column name="Description" type="String" />
</entity>

<entity name="Roles_Staff" local-service="true" remote-service="false">
<!-- PK fields -->
<column name="Id" type="Integer" primary="true" id-type="increment"/>
<!-- Normal columns -->
<column name="RoleId" type="Integer"/>
<column name="UserId" type="String" />
</entity>

<entity name="Roles_Semester" local-service="true" remote-service="false">
<!-- PK fields -->
<column name="Id" type="Integer" primary="true" id-type="increment"/>
<!-- Normal columns -->
<column name="RoleId" type="Integer"/>
<column name="SemesterId" type="Integer" />
</entity>

</service-builder>


after this I wrote some code in the JSP just like below


<%
ThemeDisplay themeDispaly=(ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
Group group = themeDispaly.getLayout().getGroup();
Long groupId = group.getGroupId();

RolesUtil.findByGroup(groupId);
%>


This is what i did in my JSP but it showing the below problem when i hit the JSP.


Caused by: org.apache.jasper.JasperException: An exception occurred processing JSP page /jsp/roles/UpdateRole.jsp at line 79

76: <option value="-1"> &lt;-- select --&gt; </option>
77: <%
78: List<Roles> roles1=null;
79: roles1=RolesUtil.findByGroup(groupId);
80: for(Roles objRoles:roles1){
81: %>
82: <option value="<%=objRoles.getPrimaryKey()%> "><b><%=objRoles.getName() %></b></option>


Stacktrace:
at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:535)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:472)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
at org.apache.jsp.jsp.roles.rolesView_jsp._jspService(rolesView_jsp.java:403)
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:374)
... 144 more
Caused by: javax.servlet.ServletException: com.liferay.portal.SystemException: java.lang.IllegalArgumentException: No positional parameters in query: FROM com.roles.model.Roles WHERE groupId = ?
at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:852)
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
at org.apache.jsp.jsp.roles.UpdateRole_jsp._jspService(UpdateRole_jsp.java:1065)
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:374)
... 157 more
Caused by: com.liferay.portal.SystemException: java.lang.IllegalArgumentException: No positional parameters in query: FROM com.roles.model.Roles WHERE groupId = ?
at com.liferay.portal.service.persistence.impl.BasePersistenceImpl.processException(BasePersistenceImpl.java:78)
at com.roles.service.persistence.RolesPersistenceImpl.findByGroup(RolesPersistenceImpl.java:391)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy549.findByGroup(Unknown Source)
at com.roles.service.persistence.RolesUtil.findByGroup(RolesUtil.java:88)
at org.apache.jsp.jsp.roles.UpdateRole_jsp._jspService(UpdateRole_jsp.java:563)
... 160 more
Caused by: java.lang.IllegalArgumentException: No positional parameters in query: FROM com.roles.model.Roles WHERE groupId = ?
at org.hibernate.impl.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:332)
at org.hibernate.impl.AbstractQueryImpl.setLong(AbstractQueryImpl.java:489)
at com.liferay.portal.dao.orm.hibernate.QueryImpl.setLong(QueryImpl.java:115)
at com.liferay.portal.kernel.dao.orm.QueryPos.add(QueryPos.java:96)
at com.roles.service.persistence.RolesPersistenceImpl.findByGroup(RolesPersistenceImpl.java:379)
... 175 more

thumbnail
Raja Nagendra Kumar,修改在12 年前。

RE: Facing a problem with findByXXX() methods in liferay plugins

Expert 帖子: 484 加入日期: 06-3-2 最近的帖子
Are u calling the method with null values.. or check if the DB schema is intact or got changed later to Service Creation..
thumbnail
guru murthy,修改在12 年前。

RE: Facing a problem with findByXXX() methods in liferay plugins

Regular Member 帖子: 208 加入日期: 11-8-12 最近的帖子
Hi Raja ,

I am getting organization / community id through themeDisplay in My JSP , so it won't be null . I passed that groupId to finder method .

Regards ...
G.Gurumurthy
thumbnail
Ketan Savaliya,修改在12 年前。

RE: Facing a problem with findByXXX() methods in liferay plugins

Regular Member 帖子: 117 加入日期: 11-3-3 最近的帖子

hi,

your code,
<%
ThemeDisplay themeDispaly=(ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
Group group = themeDispaly.getLayout().getGroup();
Long groupId = group.getGroupId();

RolesUtil.findByGroup(groupId);
%>



insted of passing this way of group id, pass themeDisplay.getScopeGroupId();

hope so it will help you,

Thankx & Regards
Ketan savaliya
thumbnail
guru murthy,修改在12 年前。

RE: Facing a problem with findByXXX() methods in liferay plugins

Regular Member 帖子: 208 加入日期: 11-8-12 最近的帖子
Hi Ketan ,

can you tell me the difference between group.getGroupId() and themeDisplay.getScopeGroupId()
thumbnail
guru murthy,修改在12 年前。

RE: Facing a problem with findByXXX() methods in liferay plugins

Regular Member 帖子: 208 加入日期: 11-8-12 最近的帖子
Ketan Savaliya:

hi,

your code,
<%
ThemeDisplay themeDispaly=(ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
Group group = themeDispaly.getLayout().getGroup();
Long groupId = group.getGroupId();

RolesUtil.findByGroup(groupId);
%>



insted of passing this way of group id, pass themeDisplay.getScopeGroupId();

hope so it will help you,

Thankx & Regards
Ketan savaliya



Hi Ketan ,

I got the goup id also when i call Long groupId = group.getGroupId(); , so there is no problem with it .
thumbnail
guru murthy,修改在12 年前。

RE: Facing a problem with findByXXX() methods in liferay plugins

Regular Member 帖子: 208 加入日期: 11-8-12 最近的帖子
Hi All ,

Still I have a problem with service builder tool in plugins V5.1.2 . I am showing the main exceptions which are came early .

1) As per findByGroupId(groupId) , the following error occurred .

javax.servlet.ServletException: com.liferay.portal.SystemException: java.lang.IllegalArgumentException: No positional parameters in query: FROM com.roles.model.Roles WHERE GroupId = ?


2) As per countByName(name) also same issue

Caught unexpected exception java.lang.IllegalArgumentException
com.liferay.portal.SystemException: java.lang.IllegalArgumentException: No positional parameters in query: SELECT COUNT(*) FROM com.roles.model.Roles WHERE Name = ?


3) next one is creating a object to [Entity]Impl class and calling the setXXX() methods of [Entity]Impl object . after that I called add[Entity]() method to store details in Database but i got below issue.

Caught ORMException
com.liferay.portal.SystemException: com.liferay.portal.kernel.dao.orm.ORMException: Unknown entity: com.roles.model.impl.[Entity]Impl


By looking those issues , i thought there is a service builder tool problem in liferay plugins (version : 5.1.2 ) with the combination of MySQL 5.1.49 , Ubuntu 10.10 - the Maverick Meerkat, Tomcat 6.0 . If not , Let me know how to resolve these issues .

Thanks in advance ...
G.Gurumurthy ,
Ryan Griffith,修改在11 年前。

RE: Facing a problem with findByXXX() methods in liferay plugins

New Member 帖子: 4 加入日期: 12-2-22 最近的帖子
This has been dead for awhile, but did you ever get this figured out? I'm running into the same issue with v5.2.
thumbnail
Gurumurthy Godlaveeti,修改在11 年前。

RE: Facing a problem with findByXXX() methods in liferay plugins

Regular Member 帖子: 208 加入日期: 11-8-12 最近的帖子
HI Ryan ,

I had a problem with this scenario when I worked . Actually I used Wrapper classes in service.xml file so it is generated service layer classes and [Entity]Util.java have findByXXX() methods . you can observe the parameters data type of each findByXXX() method . All findByXXX() methods parameters data type are primitive data type only .

findByXXX(int primaryId);


But for all findByXXX() methods , i passed Wrapper class objects as parameters so i got ORMException and some other . I resolved those by passing primitive data types to findByXXX() or countByXXX() methods . After i did this changes , there was no issue again .

So did you do the same mistake , if so then make the changes and finish it . if it is not the issue then please provide all information regarding bug .

Thanks ,
G.Gurumurthy .
Ryan Griffith,修改在11 年前。

RE: Facing a problem with findByXXX() methods in liferay plugins

New Member 帖子: 4 加入日期: 12-2-22 最近的帖子
Gurumurthy Godlaveeti:

But for all findByXXX() methods , i passed Wrapper class objects as parameters so i got ORMException and some other . I resolved those by passing primitive data types to findByXXX() or countByXXX() methods . After i did this changes , there was no issue again .


Just making sure I follow you, I should use something like type="boolean" vs type="Boolean" in my services.xml file?