Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
Yves LeGrand
Service Builder - Assembled Primary Keys and Relationships
March 28, 2012 11:55 PM

Yves LeGrand

Rank: Regular Member

Posts: 158

Join Date: November 18, 2009

Recent Posts

Hello Liferay and Community.

I am trying to set up the service.xml with a relation 1:n. A Member can have different Positions but a position is always assigned to one Member.
The entity Member must have as primary key an assembled primary key (teamId, userId).

 2<?xml version="1.0" encoding="UTF-8"?>
 3<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.0.0//EN" "">
 4<service-builder package-path="test">
 5    <author>yves</author>
 6    <namespace>test</namespace>
 8        <entity name="Member" local-service="true" remote-service="false">
 9        <column name="teamId" type="long" primary="true" />
10        <column name="userId" type="long" primary="true" />
11        <column name="companyId" type="long" />
12        <column name="position" type="Collection" entity="Position" mapping-key="positionId" />
13    </entity>
15    <entity name="Position" local-service="true" remote-service="false">
16        <column name="positionId" type="long" primary="true"/>
17        <column name="positionName" type="String" />
18    </entity>

Using the upper service.xml configuration the build-service call fails with:

 2Java backtrace for programmers:
 3     [echo] ----------
 4     [echo] freemarker.core.InvalidReferenceException: Error on line 3852, column 25 in com/liferay/portal/tools/servicebuilder/dependencies/persistence_impl.ftl
 5     [echo] serviceBuilder.getSqlType(packagePath + ".model." + entity.getName(), entity.getPKVarName(), entity.getPKClassName()) is undefined.
 6     [echo] It cannot be assigned to entitySqlType
 7     [echo]     at freemarker.core.Assignment.accept(
 8     [echo]     at freemarker.core.Environment.visit(
 9     [echo]     at freemarker.core.MixedContent.accept(
10     [echo]     at freemarker.core.Environment.visit(
11     [echo]     at freemarker.core.ConditionalBlock.accept(
12     [echo]     at freemarker.core.Environment.visit(
13     [echo]     at freemarker.core.IteratorBlock$Context.runLoop(
14     [echo]     at freemarker.core.Environment.visit(

If I use a non assembled primary key the build-service call works fine.
Can someone help me with this? What's wrong?

Thanks a lot.

Best regards,