You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Maria Huber <hu...@gmx.de> on 2021/01/29 07:58:50 UTC

Re: Single Table Inheritance with Embeddable object

Hey all,
this error is still happening on the version 4.2.M2.
It is currently not possible to include an Embeddable property into both the base and child class within an inherited relationship.
If you use the Modeler, the mentioned "Embeddable Attribute 'X' has incorrect DBAttribute mapping" error pops up.
If you directly change the map.xml, you get an error "ObjAttribute 'X' does not have a corresponding DbAttribute" (base class) or "Unable to resolve path: .Field1" (child class).
In my case, I want to add an embeddable object to the child object.
Is there any known solution or workaround for this?

To use an embeddable object without inheritance relationship works out of the box.

Kind regards,
Maria




On 2018/02/16 08:49:43, Frederic Gilbart <f....@capsiel.fr> wrote:
> Hi all,>
>
> I'm trying to use an Embeddable object with Single Table Inheritance pattern, but receive a < ObjAttribute 'X' has no DBAttribute mapping > for each overriding objects, at project validation.>
>
> Embeddable is added to the parent abstract object.>
>
> Reproduced in the BOOK example https://cayenne.apache.org/docs/3.0/modeling-single-table-inheritance.html, in the attached configuration.>
> Using 4.0B2 modeler.>
>
> Should I change my configuration to make it work, or is this a not supported feature ?>
> By the way at every click on < Sync objEntity with DbEntity > all BOOK columns even those mapped on Embeddable reappear.>
>
> Thanks for any hint.>
>
> Regards,>
> Fred>
>
>
>
> <data-map xmlns="http://cayenne.apache.org/schema/9/modelMap">
>                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>                xsi:schemaLocation="http://cayenne.apache.org/schema/9/modelMap http://cayenne.apache.org/schema/9/modelMap.xsd">
>                project-version="9">>
>                <property name="defaultPackage" value="org.example.cayenne.persistent"/>>
>                <embeddable className="org.example.cayenne.persistent.Reference">>
>                               <embeddable-attribute name="isbn" type="java.lang.String" db-attribute-name="isbn"/>>
>                               <embeddable-attribute name="title" type="java.lang.String" db-attribute-name="title"/>>
>                </embeddable>>
>                <db-entity name="BOOK">>
>                               <db-attribute name="TYPE" type="CHAR" isMandatory="true" length="1"/>>
>                               <db-attribute name="author" type="VARCHAR" isMandatory="true" length="128"/>>
>                               <db-attribute name="downloadurl" type="VARCHAR" length="128"/>>
>                               <db-attribute name="id" type="INTEGER" isPrimaryKey="true" isMandatory="true" length="8"/>>
>                               <db-attribute name="isbn" type="VARCHAR" length="128"/>>
>                               <db-attribute name="title" type="VARCHAR" length="128"/>>
>                               <db-attribute name="weight" type="VARCHAR" length="128"/>>
>                </db-entity>>
>                <obj-entity name="Book" className="org.example.cayenne.persistent.Book" dbEntityName="BOOK">>
>                               <obj-attribute name="downloadurl" type="java.lang.String" db-attribute-path="downloadurl"/>>
>                               <obj-attribute name="isbn" type="java.lang.String" db-attribute-path="isbn"/>>
>                               <embedded-attribute name="reference" type="org.example.cayenne.persistent.Reference"/>>
>                               <obj-attribute name="type" type="java.lang.String" db-attribute-path="TYPE"/>>
>                               <obj-attribute name="weight" type="java.lang.String" db-attribute-path="weight"/>>
>                </obj-entity>>
>                <obj-entity name="EBook" superEntityName="Book" className="org.example.cayenne.persistent.EBook">>
>                               <qualifier><![CDATA[type = "E"]]></qualifier>>
>                               <obj-attribute name="author" type="java.lang.String" db-attribute-path="author"/>>
>                               <obj-attribute name="title" type="java.lang.String" db-attribute-path="title"/>>
>                </obj-entity>>
>                <obj-entity name="PaperBook" superEntityName="Book" className="org.example.cayenne.persistent.PaperBook">>
>                               <qualifier><![CDATA[type = "P"]]></qualifier>>
>                               <obj-attribute name="author" type="java.lang.String" db-attribute-path="author"/>>
>                               <obj-attribute name="title" type="java.lang.String" db-attribute-path="title"/>>
>                </obj-entity>>
> </data-map>>
>
>
>
>