Re: Single Table Inheritance with Embeddable object

Maria Huber <[email protected]>
Newsgroups gmane.comp.java.cayenne.user
Message-ID <trinity-dbb564a8-5cb3-4a7f-84e7-ba7a1d3697fc-1611907130726@3c-app-gmx-bs58>
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 <[email protected]> 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>>
>
>
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.