cayenne-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Gentry <mgen...@masslight.net>
Subject To-Many Warning?
Date Wed, 13 Nov 2013 17:20:32 GMT
I just spent a couple hours debugging an issue where the model was messed
up and the to-many checkbox (in the DbEntity editors) was set on both sides
of a relationship and Cayenne was inserting NULLs for the FK and orphaning
records.  Should Cayenne Modeler give a warning when both sides are to-many
(and not a flattened many-to-many)?

Here is the XML for the issue (using 3.1B2, but the issue exists in 3.0.2
also):

~> cat cayenne-project.xml
<?xml version="1.0" encoding="utf-8"?>
<domain project-version="6">
<map name="datamap"/>
</domain>


~> cat datamap.map.xml
<?xml version="1.0" encoding="utf-8"?>
<data-map xmlns="http://cayenne.apache.org/schema/3.0/modelMap"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://cayenne.apache.org/schema/3.0/modelMap
http://cayenne.apache.org/schema/3.0/modelMap.xsd"
 project-version="6">
<db-entity name="child">
<db-attribute name="parent_fk" type="BIGINT"/>
 <db-attribute name="pk" type="BIGINT" isPrimaryKey="true"
isMandatory="true"/>
</db-entity>
 <db-entity name="parent">
<db-attribute name="pk" type="BIGINT" isPrimaryKey="true"
isMandatory="true"/>
 </db-entity>
<db-relationship name="to_parent" source="child" target="parent"
toMany="true">
 <db-attribute-pair source="parent_fk" target="pk"/>
</db-relationship>
 <db-relationship name="to_child" source="parent" target="child"
toMany="true">
<db-attribute-pair source="pk" target="parent_fk"/>
 </db-relationship>
</data-map>


Thanks,

mrg

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message