-
Type:
Bug
-
Status: Closed
-
Resolution: Won't Fix
-
Affects Version/s: 6.1.1 CE GA2, 6.2.0 CE M4
-
Fix Version/s: 6.1.1 CE GA2, 6.2.0 CE M4
-
Labels:
-
Fix Priority:3
Liferay Portal Community Edition 6.1.1 CE GA2 (Paton / Build 6101 / July 31, 2012)
I'm building a portlet for my project, the portlets has a service.xml with multiple entities, all entities us an alternative datasource. The biggest part is working fine, finders work when using only one column. When i use 2 column then liferay doesn't use the data-source of the entity but searches inside it's own database.
Example, i have a page with searchcontainer, the row are standard filter with
workItems = WorkItemLocalServiceUtil.getWorkItemByProjectId(projectId, searchContainer .getStart(), searchContainer.getEnd(), searchContainer.getOrderByComparator());
That works fine, there is only one column called projectId which is defined as a finder column in the service.xml, this query is executed on the database "dashboard".
But when a user wants to search through the data, they enter a value in the search form and then an other finder is used:
workItems = WorkItemLocalServiceUtil.getWorkItemBySearchName_ProjectId(searchByName, projectId, searchContainer.getStart(), searchContainer.getEnd(), searchContainer .getOrderByComparator());
Then i get an JDBCException:
09:33:07,297 ERROR [http-bio-8080-exec-107][JDBCExceptionReporter:76] Table 'dashboard_portal_nico.workitem' doesn't exist
com.liferay.portal.kernel.exception.SystemException: com.liferay.portal.kernel.dao.orm.ORMException: org.hibernate.exception.SQLGrammarException: could not execute query
Code:
// get items by search input or get all workitems
if (searchByName != null && searchByName != "") { workItems = WorkItemLocalServiceUtil.getWorkItemBySearchName_ProjectId(searchByName, projectId, searchContainer.getStart(), searchContainer.getEnd(), searchContainer .getOrderByComparator()); workItemTotal = WorkItemLocalServiceUtil.countBySearchName_ProjectId(searchByName, projectId); } else { workItems = WorkItemLocalServiceUtil.getWorkItemByProjectId(projectId, searchContainer .getStart(), searchContainer.getEnd(), searchContainer.getOrderByComparator()); workItemTotal = WorkItemLocalServiceUtil.getWorkItemByProjectId(projectId).size(); }
Service Builder workitem entity:
<entity name="WorkItem" local-service="true" remote-service="true" data-source="dashboardDataSource" cache-enabled="false"> <!-- PK fields --> <column name="workItemId" type="long" primary="true" /> <!-- Audit fields --> <column name="name" type="String" /> <column name="description" type="String" /> <column name="state" db-name="state" type="String" /> <column name="deadline" type="Date" /> <column name="dateStart" type="Date" /> <column name="dateEnd" type="Date" /> <column name="dateCreated" type="Date" /> <column name="dateUpdated" type="Date" /> <column name="companyId" type="long" /> <column name="type" type="String" db-name="type" /> <column name="projectId" type="long" /> <column name="parentWorkItemId" type="long" db-name="parentWorkItem" /> <column name="reporterId" type="long" /> <column name="assigneeId" type="long" /> <!-- Relationships --> <column name="persons" type="Collection" entity="Person" mapping-table="workitemhasperson" /> <!-- Order --> <order by="desc" > <order-column name="dateUpdated" order-by="desc" /> </order> <!-- Finder methods --> <finder name="ProjectId" return-type="Collection" > <finder-column name="projectId" /> </finder> <finder name="ParentWorkItem" return-type="Collection"> <finder-column name="parentWorkItemId" /> </finder> <finder name="SearchName_ProjectId" return-type="Collection" > <finder-column name="name" comparator="LIKE"/> <finder-column name="projectId" comparator="="/> </finder> </entity>