You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by Christopher Snow <sn...@coralms.com> on 2007/03/13 12:41:04 UTC

entity one

If have the following entities:

<entity entity-name="EntityOne" ...>
   <field name="entityOneId" type="id-ne"/>
   <field name="entityTwoId" type="id-ne"/>
   <prim-key field="entityOneId"/>
   <relation type="one" fk-name="ENT_TYP" rel-entity-name="EntityTwo">
      <key-map field-name="entityTwoId"/>
   </relation>
</entity>

<entity entity-name="EntityTwo" ..."> 
   <field name="entityTwoId" type="id-ne"/>
   <prim-key field="entityTwoId"/>
</entity>

I thought the relation type "one" would only allow me to have a value
for EntityOne.entityTwoId of either null or a value that exists in
EntityTwo.entityTwoId.  However:

bsh % e2 = delegator.findAll("EntityTwo");
bsh % print(e2);
[]
bsh % e1 = delegator.create("EntityOne", UtilMisc.toMap("entityOneId",
"1", "entityTwoId", "THIS_KEY_DOESNT_EXIST")); // this should err??

bsh % print(e1);
[GenericEntity:EntityOne][entityOneId,1(java.lang.String)] ...
[THIS_KEY_DOESNT_EXIST(java.lang.String)] ...

Where am I going wrong?

Many thanks ...