On 26/01/12 11:00 AM, ngong wrote:
Something I missed with the modeler.
I created a model with two tables in modeler: MASTER and DETAIL.
MASTER has ID as the PK and NAME as an attribute.
DETAIL has a two column PK: MASTER and COUNT, and a NAME attribute as well.
The MASTER column is also a relationship to the MASTER TABLE.
When I create object entities, the COUNT field is missing at all.
Here is the the regarding 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">
<property name="defaultPackage"
value="eu.ngong.test.cayenne.persistent"/>
<db-entity name="DETAIL">
<db-attribute name="COUNT" type="INTEGER" isPrimaryKey="true"
isMandatory="true"/>
<db-attribute name="MASTER" type="INTEGER" isPrimaryKey="true"
isMandatory="true"/>
<db-attribute name="NAME" type="VARCHAR" length="256"/>
</db-entity>
<db-entity name="MASTER">
<db-attribute name="ID" type="INTEGER" isPrimaryKey="true"
isMandatory="true"/>
<db-attribute name="NAME" type="VARCHAR" length="256"/>
</db-entity>
<obj-entity name="Detail"
className="eu.ngong.test.cayenne.persistent.Detail" dbEntityName="DETAIL">
<obj-attribute name="name" type="java.lang.String"
db-attribute-path="NAME"/>
</obj-entity>
<obj-entity name="Master"
className="eu.ngong.test.cayenne.persistent.Master" dbEntityName="MASTER">
<obj-attribute name="name" type="java.lang.String"
db-attribute-path="NAME"/>
</obj-entity>
<db-relationship name="toMaster" source="DETAIL" target="MASTER"
toMany="false">
<db-attribute-pair source="MASTER" target="ID"/>
</db-relationship>
<db-relationship name="toDetail" source="MASTER" target="DETAIL"
toDependentPK="true" toMany="true">
<db-attribute-pair source="ID" target="MASTER"/>
</db-relationship>
<obj-relationship name="toDetail" source="Master" target="Detail"
deleteRule="Deny" db-relationship-path="toDetail"/>
</data-map>
Any idea for me why obj-entity Deail is missing the count attribute?
You didn't add it in the modeler.
Also, "count" is a bad dbAttribute name. It may work since Cayenne will quote
identifiers, but on the whole I think it is a bad idea to pick reserved SQL keywords.
Ari
--
-------------------------->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A