Leaving out rel-field-name in keymap causes NPE
-----------------------------------------------

                 Key: OFBIZ-1187
                 URL: https://issues.apache.org/jira/browse/OFBIZ-1187
             Project: OFBiz
          Issue Type: Bug
            Reporter: Leon Torres


If you leave out the rel-field-name for a keymap that requires it, 
DatabaseUtil.java will crash with a NPE when trying to create it.

To reproduce, add the following to an entityengine.xml,

    <extend-entity entity-name="OrderAdjustment">
        <field name="orderAdjustmentSubTypeId" type="id"/>
        <relation type="one" fk-name="ORDER_ADJ_SUBTYPE" 
rel-entity-name="OrderAdjustmentType">
            <key-map field-name="orderAdjustmentSubTypeId" />
        </relation>
    </extend-entity>

Note that the <key-map> is missing a rel-field-name="orderAdjustmentTypeId".   
Do an ant run-install to create the key.  It should crash with a NPE pointing 
to line 2150 in DatabaseUtil.java:

            ModelField relField = 
relModelEntity.getField(keyMap.getRelFieldName());

I believe it should be testing that getRelFieldName() is null, and if so then 
log a warning and skip the key.



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to