You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Simon Farner <s....@bluewin.ch> on 2016/03/28 14:12:29 UTC

Trouble with modeling vertical inheritance

Hello everybody

I am trying to get the book/ebook/paper_book example to work with
Cayenne Modler 4.0.M3, but it wont validate. This is the third time I
try this and I really need to get this working now, I am not very keen
on a road block meeting and switching to another ORM.

I strugle with the relationships between superclass table and subclass
table. I set up two relation ships in BOOK

	Name:"paperBook",Target:"PAPER_BOOK", To Dep PK:True, To
Many:False
	Name:"eBook",Target:"E_BOOK", To Dep PK:True, To Many:False

I then first create the ObjEntities for all three. Then I enter the
type classifier field and set the inheritance. Afterwards I go to the
two subclasses and map the two individual attributes they posses to the
right subclass attribut. Then I save the project and the validation
tells me that that all the ObjRelationships have uncompelte mappings.

Example: "ObjRelationship book.eBook has incomplete DbRelationship
mapping"

I then go to Book ObjEntity and open both relationships to the subclass
once, but I change nothing. Opon closing I am asked if I want to save
my changes, because I some how have magically modified the path. I say
yes. Then I validat again  and all but two complaints are gone. Left
over are:

	"ObjRelationship EBook.book has incomplete DbRelationship
mapping"
	"ObjRelationship PaperBook.book has incomplete DbRelationship
mapping"

Those are the relation ships pointing back from the subclasses to the
super clases. I can't fix them. When I open the edit dialog and book is
allready pre selected as target.##SELECTION_END##

Can please someone help me to find out what I am doing wrong? I kind of
feel stupid about asking here, because it is so trivial :/ But I really
need this working. If someone wants to have a look at my example
cayenne project I put it on my drop box: https://www.dropbox.com/s/uw82
cl1yxkl3ohk/cayenne-project.xml?dl=0

Best regards and thanks to everybody for helping
Simon

Re: Trouble with modeling vertical inheritance

Posted by Andrus Adamchik <an...@objectstyle.org>.
Just applied a pull request that fixes the issue to master per these links:

https://lists.apache.org/thread.html/6561a3d616680468e36e173ad016c1b683024b12a35dfd5cae13c790@%3Cuser.cayenne.apache.org%3E
https://issues.apache.org/jira/browse/CAY-2070
https://github.com/apache/cayenne/pull/92

Andrus


> On Mar 30, 2016, at 1:16 PM, Simon Farner <s....@bluewin.ch> wrote:
> 
> I will try this today. Reading it just in an mail I am still a bit
> confused about what relationships are ultimate needed and which need to
> be deleted, but I figure this will sort itself out when I get to play
> around with it this evening
> 
> Thank you for helping me out to everybody. If you eventually get around
> to fix this I will be glad to offer my help in turn and try it out.
> 
> Best regards
> Simon
>> 
>> "Sync ObjEntity with DbEntity" button in the Modeler insists on
>> adding these relationships back (which is a bug and we need to
>> address it). So make sure you delete those, if they are ever created
>> during sync.
>> 
>> HTH,
>> Andrus
>> 
>> --- a/datamap.map.xml
>> +++ b/datamap.map.xml
>> @@ -90,10 +90,6 @@
>>         <db-relationship name="book" source="PAPER_BOOK"
>> target="BOOK" toMany="false">
>>                 <db-attribute-pair source="ID" target="ID"/>
>>         </db-relationship>
>> -       <obj-relationship name="eBook" source="Book" target="EBook"
>> deleteRule="Nullify" db-relationship-path="eBook.book"/>
>> -       <obj-relationship name="paperBook" source="Book"
>> target="Book" deleteRule="Nullify" db-relationship-
>> path="paperBook.book"/>
>> -       <obj-relationship name="book" source="EBook" target="Book"
>> deleteRule="Nullify" db-relationship-path=""/>
>>         <obj-relationship name="artist" source="Painting"
>> target="Artist" deleteRule="Nullify" db-relationship-path="artist"/>
>>         <obj-relationship name="gallery" source="Painting"
>> target="Gallery" deleteRule="Nullify" db-relationship-
>> path="gallery"/>
>> -       <obj-relationship name="book" source="PaperBook"
>> target="Book" deleteRule="Nullify" db-relationship-path=""/>
>> 


Re: Trouble with modeling vertical inheritance

Posted by Simon Farner <s....@bluewin.ch>.
I will try this today. Reading it just in an mail I am still a bit
confused about what relationships are ultimate needed and which need to
be deleted, but I figure this will sort itself out when I get to play
around with it this evening

Thank you for helping me out to everybody. If you eventually get around
to fix this I will be glad to offer my help in turn and try it out.

Best regards
Simon
>
> "Sync ObjEntity with DbEntity" button in the Modeler insists on
> adding these relationships back (which is a bug and we need to
> address it). So make sure you delete those, if they are ever created
> during sync.
> 
> HTH,
> Andrus
> 
> --- a/datamap.map.xml
> +++ b/datamap.map.xml
> @@ -90,10 +90,6 @@
>         <db-relationship name="book" source="PAPER_BOOK"
> target="BOOK" toMany="false">
>                 <db-attribute-pair source="ID" target="ID"/>
>         </db-relationship>
> -       <obj-relationship name="eBook" source="Book" target="EBook"
> deleteRule="Nullify" db-relationship-path="eBook.book"/>
> -       <obj-relationship name="paperBook" source="Book"
> target="Book" deleteRule="Nullify" db-relationship-
> path="paperBook.book"/>
> -       <obj-relationship name="book" source="EBook" target="Book"
> deleteRule="Nullify" db-relationship-path=""/>
>         <obj-relationship name="artist" source="Painting"
> target="Artist" deleteRule="Nullify" db-relationship-path="artist"/>
>         <obj-relationship name="gallery" source="Painting"
> target="Gallery" deleteRule="Nullify" db-relationship-
> path="gallery"/>
> -       <obj-relationship name="book" source="PaperBook"
> target="Book" deleteRule="Nullify" db-relationship-path=""/>
> 

Re: Trouble with modeling vertical inheritance

Posted by Andrus Adamchik <an...@objectstyle.org>.
> On Mar 28, 2016, at 10:22 PM, Simon Farner <s....@bluewin.ch> wrote:
> 
>>  
>> Ok, that's cayenne.xml. Do you also have a *.map.xml? That's the main
>> ORM file.
>> 
> Offcourse I can provide you with this file. I should now be able to get
> it from https://www.dropbox.com/s/bdc3xg8qjifhlpf/datamap.map.xml?dl=0
> 
> Now I also sorted out the reply address. You shouldn't have this pop up
> in moderation now. And thank you for your patience again. You must all
> think I am the biggest dork ever. Hard to believe that I work with
> computers for a living :P

What confused the Modeler is 2 ObjRelationships from subclasses back to superclass. They are not needed, and once you delete them, the model validates (see the diff below - I removed a total of 4 Obj* relationships between base class and subclasses). 

"Sync ObjEntity with DbEntity" button in the Modeler insists on adding these relationships back (which is a bug and we need to address it). So make sure you delete those, if they are ever created during sync.

HTH,
Andrus

--- a/datamap.map.xml
+++ b/datamap.map.xml
@@ -90,10 +90,6 @@
        <db-relationship name="book" source="PAPER_BOOK" target="BOOK" toMany="false">
                <db-attribute-pair source="ID" target="ID"/>
        </db-relationship>
-       <obj-relationship name="eBook" source="Book" target="EBook" deleteRule="Nullify" db-relationship-path="eBook.book"/>
-       <obj-relationship name="paperBook" source="Book" target="Book" deleteRule="Nullify" db-relationship-path="paperBook.book"/>
-       <obj-relationship name="book" source="EBook" target="Book" deleteRule="Nullify" db-relationship-path=""/>
        <obj-relationship name="artist" source="Painting" target="Artist" deleteRule="Nullify" db-relationship-path="artist"/>
        <obj-relationship name="gallery" source="Painting" target="Gallery" deleteRule="Nullify" db-relationship-path="gallery"/>
-       <obj-relationship name="book" source="PaperBook" target="Book" deleteRule="Nullify" db-relationship-path=""/>


Re: Trouble with modeling vertical inheritance

Posted by Simon Farner <s....@bluewin.ch>.
Hello again

> We fixed a few similar issues in M3:
> 
> https://issues.apache.org/jira/browse/CAY-2047
> https://issues.apache.org/jira/browse/CAY-2049
> 
> wonder if there are more to deal with.
If I can helpe I'll provide all the info you need. Just ask for what
you need.

> 
> Ok, that's cayenne.xml. Do you also have a *.map.xml? That's the main
> ORM file.
> 
Offcourse I can provide you with this file. I should now be able to get
it from https://www.dropbox.com/s/bdc3xg8qjifhlpf/datamap.map.xml?dl=0

Now I also sorted out the reply address. You shouldn't have this pop up
in moderation now. And thank you for your patience again. You must all
think I am the biggest dork ever. Hard to believe that I work with
computers for a living :P

Re: Trouble with modeling vertical inheritance

Posted by Andrus Adamchik <an...@objectstyle.org>.
Hi again,


> What I am trying to achive is this: https://cayenne.apache.org/docs/3.0/modeling-vertical-inheritance.html The section in the 4.0 Version of the Guid is empty so I assumed this is still valid.

Yes, it is.

> I strugle with the relationships between superclass table and subclass
> table. I set up two relation ships in BOOK
> 
> 	Name:"paperBook",Target:"PAPER_BOOK", To Dep PK:True, To
> Many:False
> 	Name:"eBook",Target:"E_BOOK", To Dep PK:True, To Many:False

This looks about right. 

> I then first create the ObjEntities for all three. Then I enter the
> type classifier field and set the inheritance. Afterwards I go to the
> two subclasses and map the two individual attributes they posses to the
> right subclass attribut. Then I save the project and the validation
> tells me that that all the ObjRelationships have uncompelte mappings.

[..]

We fixed a few similar issues in M3:

https://issues.apache.org/jira/browse/CAY-2047
https://issues.apache.org/jira/browse/CAY-2049

wonder if there are more to deal with.

> If someone wants to have a look at my example
> cayenne project I put it on my drop box: https://www.dropbox.com/s/uw82
> cl1yxkl3ohk/cayenne-project.xml?dl=0

Ok, that's cayenne.xml. Do you also have a *.map.xml? That's the main ORM file.

Andrus

Re: Trouble with modeling vertical inheritance

Posted by Andrus Adamchik <an...@objectstyle.org>.
Simon, you are not subscribed to the list I guess. So you are missing the replies to your original message. Please check the archives. There were some: http://www.mail-archive.com/user@cayenne.apache.org/msg09239.html

Andrus

> On Mar 28, 2016, at 3:12 PM, Simon Farner <s....@bluewin.ch> wrote:
> 
> Hello everybody
> 
> I am trying to get the book/ebook/paper_book example to work with
> Cayenne Modler 4.0.M3, but it wont validate. This is the third time I
> try this and I really need to get this working now, I am not very keen
> on a road block meeting and switching to another ORM.
> 
> I strugle with the relationships between superclass table and subclass
> table. I set up two relation ships in BOOK
> 
> 	Name:"paperBook",Target:"PAPER_BOOK", To Dep PK:True, To
> Many:False
> 	Name:"eBook",Target:"E_BOOK", To Dep PK:True, To Many:False
> 
> I then first create the ObjEntities for all three. Then I enter the
> type classifier field and set the inheritance. Afterwards I go to the
> two subclasses and map the two individual attributes they posses to the
> right subclass attribut. Then I save the project and the validation
> tells me that that all the ObjRelationships have uncompelte mappings.
> 
> Example: "ObjRelationship book.eBook has incomplete DbRelationship
> mapping"
> 
> I then go to Book ObjEntity and open both relationships to the subclass
> once, but I change nothing. Opon closing I am asked if I want to save
> my changes, because I some how have magically modified the path. I say
> yes. Then I validat again  and all but two complaints are gone. Left
> over are:
> 
> 	"ObjRelationship EBook.book has incomplete DbRelationship
> mapping"
> 	"ObjRelationship PaperBook.book has incomplete DbRelationship
> mapping"
> 
> Those are the relation ships pointing back from the subclasses to the
> super clases. I can't fix them. When I open the edit dialog and book is
> allready pre selected as target.##SELECTION_END##
> 
> Can please someone help me to find out what I am doing wrong? I kind of
> feel stupid about asking here, because it is so trivial :/ But I really
> need this working. If someone wants to have a look at my example
> cayenne project I put it on my drop box: https://www.dropbox.com/s/uw82
> cl1yxkl3ohk/cayenne-project.xml?dl=0
> 
> Best regards and thanks to everybody for helping
> Simon