You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by "Leon Torres (JIRA)" <ji...@apache.org> on 2007/08/07 22:37:59 UTC

[jira] Commented: (OFBIZ-1187) Leaving out rel-field-name in keymap causes NPE

    [ https://issues.apache.org/jira/browse/OFBIZ-1187?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12518247 ] 

Leon Torres commented on OFBIZ-1187:
------------------------------------

I made this major because once the crash happens, all keys after this one are not created.  For someone not familiar with how the entity engine works, this can be very mysterious, so we should at least log a warning.

> 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.