entity one

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

entity one

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