Skip to Content
0
Sep 22, 2020 at 06:35 PM

Horizontal Mapping as Method of Inheritance of Persistent Classes

62 Views

Hello,

I am currently trying to look deeper into persistent classes. I have worked with persistent classes before. I only mapped one database table as persistent class.

Now I want to understand inheritance in more detail.The help page for persistent classes contains a brief description of the horizontal mapping. I have come up with the following example to explain my problems:

There are two database tables Z_CAR and Z_TRUCK. The two tables are mapped using the persistent classes ZCL_CAR and ZCL_TRUCK. Each car and truck is a vehicle. The superclass ZCL_VEHICLE is to be used for this. There should be no database table for the superclass. Each vehicle has an engine power.

If I have understood the help page correctly, then I have to create the superclass as an abstract class. This is what I have done.

I created the two classes ZCL_CAR and ZCL_TRUCK as persistent classes as well and they are derived from the superclass ZCL_VEHICLE.

How can I now define the persistent attribute "power" in the superclass ZCL_VEHICLE?

If I maintain an attribute in the "Attributes" tab, then a transient attribute is created and not a persistent attribute. So this way is definitely wrong.

I cannot add a table in the persistence representation because there should be no database table for the class ZCL_VEHICLE. I want to use horizontal mapping, so the attribute "power" is defined in the tables Z_CAR and Z_TRUCK, if I am not wrong.

I also thought that I might have to use a structure. Therefore I created the structure ZSTRUCT_VEHICLE with the field "power". But somehow I can't manage to add this attribute to the class ZCL_VEHICLE. If I double-click on the "power" field, nothing happens.

I'm pretty sure this is a stupid operating error on my part. And I would be very grateful if you could help me with my problem.

Thank you very much

Thomas

Attachments

example.png (71.0 kB)
example2.png (17.7 kB)
example3.png (86.4 kB)