Hi I am using Liferay SKD for Java and Liferay 6.1(Tomcat). I have created custom database as follows:
<entity name="PCustomer" local-service="true" remote-service="false">
<!-- PK fields -->
<column name="customerId" type="int" primary="true" />
<!-- Audit fields -->
<column name="name" type="String"/>
<column name="vAddress" type="String"/>
<column name="pAddress" type="String"/>
<column name="comments" type="String"/>
<column name="pusers" type="Collection" entity="PUser" mapping-key="userId"/>
<column name="pcontacts" type="Collection" entity="PContact" mapping-key="contactId"/>
<column name="pdemos" type="Collection" entity="PUserDemo" mapping-key="demoId"/>
<column name="plicenses" type="Collection" entity="PLicense" mapping-key="licenseId"/>
<column name="pfolders" type="Collection" entity="PFolder" mapping-key="folderId"/>
</entity>
Using Service.xml and now I want to retrieve all of my contacts associated with certain customer. The problem is that when I do this in my JSP page:
<%
String user = request.getRemoteUser();
int userId = Integer.valueOf(user);
PUser pUser=PUserLocalServiceUtil.getPUser(userId);
int customerId = pUser.getCustomerId();
PCustomer customer=PCustomerLocalServiceUtil.getPCustomer(customerId);
java.util.List<PContact> contCus=PCustomerUtil.getPContacts(customerId);
%>
And try to go trough this list using for each loop:
%for (PContact pContact : contCus)
if(pContact.getUserType().equals("billing"))
{%> DO SOMETHING <% } %>
It gives me an error:
java.lang.ClassCastException: $Proxy288 cannot be cast to com.myportlet.service.persistence.PCustomerPersistence
I debugged it and all of the values are OK and its working until it try to make the list in the JSP page. The thing is that in the page it is showing me that I have to construct the list like that. Using this parameters and so on. It doesn't give me any errors.
Can someone help me or tell me what am I doing wrong?
Any help will be appreciated. Thanks in advance!!!!