You are trying to do multiple-table inheritance? Unless I'm mistaken, I don't believe that has been implemented yet. Cayenne can do in-table inheritance using a discriminator column.
On Thu, Sep 24, 2009 at 1:10 PM, Dave Lamy <[email protected]> wrote: > Hey guys-- > > I'm attempting to model some inheritance for the first time and it's not > working yet. Here's my situation: > > My model is to have a non-abstract parent class->table and then > subclass->tables like so: > > First I should doublecheck to make sure my mapping XML looks OK: > > <db-entity name="ASSET_CONTENT"> > ... > <db-attribute name="CONTENT_TYPE" type="VARCHAR" length="50"/> > <db-attribute name="ID" type="INTEGER" isPrimaryKey="true" > isGenerated="true" isMandatory="true"/> > ... > </db-entity> > <db-entity name="IMAGE_ASSET_CONTENT"> > <db-attribute name="HEIGHT" type="INTEGER"/> > <db-attribute name="ID" type="INTEGER" isPrimaryKey="true" > isMandatory="true"/> > <db-attribute name="WIDTH" type="INTEGER"/> > </db-entity> > <obj-entity name="AssetContent" > className="com.routeto1.asset.filesystem.AssetContent" > lock-type="optimistic" dbEntityName="ASSET_CONTENT" > superClassName="com.routeto1.data.impl.DynamicDataObject"> > <obj-attribute name="contentType" type="java.lang.String" > db-attribute-path="CONTENT_TYPE"/> > ... > <pre-persist method-name="prePersist"/> > </obj-entity> > <obj-entity name="ImageAssetContent" superEntityName="AssetContent" > className="com.routeto1.asset.filesystem.ImageAssetContent" > lock-type="optimistic" dbEntityName="IMAGE_ASSET_CONTENT"> > <qualifier><![CDATA[contentType = "IMAGE"]]></qualifier> > <obj-attribute name="height" type="java.lang.Integer" > db-attribute-path="HEIGHT"/> > <obj-attribute name="width" type="java.lang.Integer" > db-attribute-path="WIDTH"/> > </obj-entity> > > Not sure if I need to provide you any more than that. Cayenne accepts the > config fine, but when I create a new ImageAssetContent and save it, Cayenne > only saves to the IMAGE_ASSET_CONTENT table: > > 2009-09-24 10:30:53,602 INFO [org.apache.cayenne.access.QueryLogger] - > <INSERT INTO IMAGE_ASSET_CONTENT (HEIGHT, ID, WIDTH) VALUES (?, ?, ?)> > 2009-09-24 10:30:53,656 INFO [org.apache.cayenne.access.QueryLogger] - > <[batch bind: 1->HEIGHT:440, 2->ID:220, 3->WIDTH:495]> > > I've confirmed that there is data in the object that should be getting saved > to the ASSET_CONTENT table but is not. > > What's also interesting is that it is pulling an auto PK value (this is > running on a Derby DB for testing): > > 2009-09-24 10:30:53,258 INFO [org.apache.cayenne.access.QueryLogger] - > <SELECT NEXT_ID FROM AUTO_PK_SUPPORT WHERE TABLE_NAME = ? FOR UPDATE [bind: > 1:'IMAGE_ASSET_CONTENT']> > > Not so interesting that it's pulling one, but for IMAGE_ASSET_CONTENT? I'd > assume it would be pulling for ASSET_CONTENT and reusing that ID in both the > parent and child tables. > > Am I missing something really basic? > > I've tested this on 3.0 M5 and M6 with same results. > > Dave >
