Hi devs,
I am trying to set this service up.
<service name="createPortalPagePortlet"
default-entity-name="PortalPagePortlet" engine="entity-auto" invoke="create"
auth="true">
<description>Add a registered PortalPortlet to a
PortalPage</description>
<auto-attributes include="pk" mode="IN" optional="false"/>
<auto-attributes include="nonpk" mode="IN" optional="true"/>
<override name="sequenceNum" mode="OUT" optional="true"/>
</service>
to create this entity:
<entity entity-name="PortalPagePortlet"
package-name="org.ofbiz.common.portal"
title="Defines Portlets included into Portal Pages">
<field name="portalPageId" type="id-ne"></field>
<field name="portalPortletId" type="id-ne"></field>
<field name="sequenceNum" type="id-ne"><description>Identify
the portalPortlet instance in case more copy of the same portalPortlet are
present in the same portalPage</description></field>
<field name="columnNum" type="numeric"></field>
<field name="rowNum" type="numeric"></field>
<prim-key field="portalPageId"/>
<prim-key field="portalPortletId"/>
<prim-key field="sequenceNum"/>
</entity>
It was OK before adding the sequenceNum field as PK and adding the
<override>.
Now what I would like to get is the sequenceNum auto-generation.
But the framework tells me:
Error doing entity-auto operation for entity [PortalPagePortlet] in service
[createPortalPagePortlet]: org.ofbiz.service.GenericServiceException: In
Service [createPortalPagePortlet] which uses the entity-auto engine with the
create invoke option: could not find a valid combination of primary key
settings to do a known create operation; options include: 1. a single OUT pk
for primary auto-sequencing, 2. a single INOUT pk for primary
auto-sequencing with optional override, 3. a 2-part pk with one part IN
(existing primary pk) and one part OUT (the secdonary pk to sub-sequence, 4.
all pk fields are IN for a manually specified primary key
Digging into the code It seems to me that it is not possible to have the
sequenceNum auto-generation in the case of a 3-parts PK.
Am I correct?
Any work-around?
Should I switch to engine="simple" and use the code that is indicated as
comment in EntityAutoEngine.java ?
<make-value entity-name="ExampleItem"
value-name="newEntity"/>
<set-pk-fields map-name="parameters"
value-name="newEntity"/>
<make-next-seq-id value-name="newEntity"
seq-field-name="exampleItemSeqId"/> <!-- this finds the next sub-sequence ID
-->
<field-to-result field-name="newEntity.exampleItemSeqId"
result-name="exampleItemSeqId"/>
<set-nonpk-fields map-name="parameters"
value-name="newEntity"/>
<create-value value-name="newEntity"/>
Many thanks,
Bruno