Hi Julia,
With a bit of tweaking of the model I was able to get a query like that:
SELECT t0.LAST_MODIFIED_TIME, t0.COLLECTION_TYPE_ID, t0.AUTO_OPEN_DATE, t0.SNAPSHOT_DATE, t0.DESCRIPTION, t0.SUPT_APPROVAL_REQD, t0.LAST_MODIFIED_BY, t0.ACTIVE_IND, t0.AUTO_CLOSE_DATE, t0.COLLECTION_NAME, t1.SCHOOL_YEAR, t0.DATA_COLLECTION_ID FROM ESDM.DATA_COLLECTION t0 LEFT JOIN ESDM.K12_DATA_COLLECTION t1 ON (t0.DATA_COLLECTION_ID = t1.DATA_COLLECTION_ID) WHERE t0.COLLECTION_TYPE_ID = ? [bind: 1->COLLECTION_TYPE_ID:3]
A few things that I changed:
* Removed explicit "Table" mapping from subclass. I.e.
<obj-entity name="K12DataCollection" className="com.escholar.datamgr.model.K12DataCollection" dbEntityName="K12_DATA_COLLECTION">
Should be
<obj-entity name="K12DataCollection" className="com.escholar.datamgr.model.K12DataCollection">
Even though the table is the same as superclass, it seemed to confuse Cayenne. I will open a Jira to add a validation check for this condition.
* There was a warning in your DataMap about DataCollection.k12DataCollection ObjRelationship. So I removed it as it is uneeded. (DbRelationship should stay though).
Let me know if you have further questions. Vertical inheritance is a fairly recent addition to Cayenne, so we may not catch/handle all deviations from the standard mapping. You feedback is very helpful in this regard.
Cheers,
Andrus
On Aug 25, 2010, at 7:10 PM, Julia Filho wrote:
>
> Hi,
>
> Is vertical inheritance not supported in Cayenne 3.0? According to the
> documentation, vertical inheritance is supported, but I am running into
> problems with the generated SELECT query when reading one of the subclasses:
>
> The generated query is:
>
> SELECT t0.DATA_COLLECTION_ID, t0.COLLECTION_TYPE_ID, t0.DATA_COLLECTION_ID,
> t0.SCHOOL_YEAR, t0.SNAPSHOT_DATE FROM ESDM.K12_DATA_COLLECTION t0 JOIN
> ESDM.DATA_COLLECTION t1 ON (t0.DATA_COLLECTION_ID = t1.DATA_COLLECTION_ID)
> JOIN ESDM.DATA_COLLECTION_TYPE t2 ON (t1.COLLECTION_TYPE_ID =
> t2.COLLECTION_TYPE_ID) WHERE t2.COLLECTION_TYPE_ID = ? [bind:
> 1->COLLECTION_TYPE_ID:3]
>
>
> which is a problem because
> 1) column COLLECTION_TYPE_ID is in select list for the subclass
> (K12_DATA_COLLECTION) but that column is in the super class table
> (DATA_COLLECTION), not the subclass
> 2) DATA_COLLECTION_ID is in the K12_DATA_COLLECTION select list twice.
>
> Do you have any suggestions, or is this functionality not yet supported?
>
> thank you for any assistance you can give
> Julie
>
>
> --
> View this message in context: http://cayenne.195.n3.nabble.com/Vertical-inheritance-tp827636p1334340.html
> Sent from the Cayenne - Dev mailing list archive at Nabble.com.
>
This archive was generated by hypermail 2.0.0 : Fri Aug 27 2010 - 08:00:27 UTC