You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by Patrick <pa...@gmail.com> on 2010/02/18 16:51:53 UTC

What's the appropriate way to modify ViewEntities?

What's the appropriate way to modify a viewEntity?  I have a
viewEntity, FacilityAndContactMechAndAddress, and it has 3 primary
keys, but they don't seem to work as expected.   I tried the code
below, but it says bad primary key.   Am I taking the wrong approach?
Also do you think I should do this at the java service level or the
simple-method level?

<!-- this didn't quite work, bad primary key (but this works if I
change entity-name to Facility for facility fields)  -->
<set field="lookupPKMap.facilityId" from-field="parameters.facilityId"/>
 <find-by-primary-key entity-name="FacilityAndContactMechAndAddress"
map="lookupPKMap" value-field="facilityId"/>
 <set-nonpk-fields map="parameters" value-field="facilityId"/>
<store-value value-field="facilityId"/>	

Thanks
Patrick

Re: What's the appropriate way to modify ViewEntities?

Posted by Scott Gray <sc...@hotwaxmedia.com>.
Hi Patrick

From memory, a view entity will only be modifiable if the primary keys for all included entities are present.

As a best practice, you should generally only perform write/update/delete operations on entities via the services available, doing so will ensure that all related SECAs are run.

Regards
Scott

HotWax Media
http://www.hotwaxmedia.com

On 18/02/2010, at 8:51 AM, Patrick wrote:

> What's the appropriate way to modify a viewEntity?  I have a
> viewEntity, FacilityAndContactMechAndAddress, and it has 3 primary
> keys, but they don't seem to work as expected.   I tried the code
> below, but it says bad primary key.   Am I taking the wrong approach?
> Also do you think I should do this at the java service level or the
> simple-method level?
> 
> <!-- this didn't quite work, bad primary key (but this works if I
> change entity-name to Facility for facility fields)  -->
> <set field="lookupPKMap.facilityId" from-field="parameters.facilityId"/>
> <find-by-primary-key entity-name="FacilityAndContactMechAndAddress"
> map="lookupPKMap" value-field="facilityId"/>
> <set-nonpk-fields map="parameters" value-field="facilityId"/>
> <store-value value-field="facilityId"/>	
> 
> Thanks
> Patrick