How is class inheritance supposed to work?

57 views
Skip to first unread message

Sendu Bala

unread,
Aug 24, 2015, 6:37:49 AM8/24/15
to OrientDB
In Studio 2.1, I created a class X with 2 properties. Then I created Y as a subclass of X since it was to have the same 2 properties. Then I created Z as a subclass of X since it was to have the same 2 properties, plus another. But adding the extra property to Z also added the property to X and Y. Likewise, with class A being a subclass of X, deleting a property of A also deletes it from X.

Is this a bug in Studio, or is this expected behaviour of classes and subclasses? If a subclass can't have different properties compared to it's parent, what is the intended use of inheritance?

MV-dev1

unread,
Aug 24, 2015, 5:16:27 PM8/24/15
to OrientDB
I thought it worked exactly like you expected it to work.

Maybe I haven't tried more than 2 levels.  I did just write a post here about it combining a single INDEX over all children -- maybe this was a newly introduced issue?

I tried to use OrientDB for something a 5 months ago but eventually gave up and went back to MSSQL however I think the concepts here are the greatest things I've seen since C++ added OOP features to C and that was 1989!

alessand...@gmail.com

unread,
Aug 25, 2015, 4:39:56 AM8/25/15
to OrientDB
Hi,
I created a class X with 2 properties.
I created a class Y that inherit from X.
I created a class Z that inherit from X and I added a new property.
Adding the new property to Z, it isn't added to class X and class Y but only at the class Z.

I created a class A that inherit from X.
If I try to delete the property1(inherit from X) from class A, I get this error:
com.orientechnologies.orient.core.exception.OSchemaException: Property 'property1' not found in class A'
Being A a subclass of X you can't delete a property inherited because A would not be anymore a subclass of X .

Regards,
Alessandro

Sendu Bala

unread,
Aug 25, 2015, 4:44:51 AM8/25/15
to OrientDB
Woops, looks like I got confused; it was indexes of properties that were not independent.
Are you supposed to create abstract classes with unindexed properties, and then create the index for those properties in each subclass?

alessand...@gmail.com

unread,
Aug 25, 2015, 5:22:06 AM8/25/15
to OrientDB
Hi,
I created an abstract class X with one property and an index on that property.
I create a class Y that inherit from X, it inherit the property and the index.
I deleted the index inherited from class Y and the index was deleted also from class X.
I thought that would not allow to delete the index from class X and Y.

Regards,
Alessandro

Reply all
Reply to author
Forward
0 new messages