{"id":21430094,"url":"https://github.com/cuba-platform/sample-entity-inheritance","last_synced_at":"2025-03-16T21:44:46.484Z","repository":{"id":85315565,"uuid":"55236727","full_name":"cuba-platform/sample-entity-inheritance","owner":"cuba-platform","description":"DEPRECATED. See https://www.cuba-platform.com/guides/data-modelling-entity-inheritance","archived":false,"fork":false,"pushed_at":"2018-08-20T05:55:59.000Z","size":147,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":29,"default_branch":"master","last_synced_at":"2025-01-23T08:19:29.293Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cuba-platform.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-04-01T14:03:57.000Z","updated_at":"2024-07-31T16:42:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"75a08ab9-be91-4633-b91f-e14d383c95fe","html_url":"https://github.com/cuba-platform/sample-entity-inheritance","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuba-platform%2Fsample-entity-inheritance","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuba-platform%2Fsample-entity-inheritance/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuba-platform%2Fsample-entity-inheritance/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuba-platform%2Fsample-entity-inheritance/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cuba-platform","download_url":"https://codeload.github.com/cuba-platform/sample-entity-inheritance/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243940063,"owners_count":20372044,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-22T22:20:39.770Z","updated_at":"2025-03-16T21:44:46.457Z","avatar_url":"https://github.com/cuba-platform.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Entity Inheritance\n\nThis project demonstrates how to use entity inheritance in CUBA applications.\n\n## Objective\nn\nLet's assume that we have two types of customers - companies and individuals, which have some common attributes. We would like to store the common attributes in one table, and use separate linked tables to store specific attributes.\n\nSo the data model contains the `Customer` entity, which is a base class stored in the `DEMO_CUSTOMER` table. The `Company` and `Person` entities stored in separate tables with foreign keys that reference the base table.\n\n`Company` and `Person` entities have their own browser and editor screens, as well as a common browser available at _Customers (all in one list)_ menu item. When you create a customer from this browser, you have to choose the customer type, and the application shows an appropriate edit screen.  \n\nThe `Order` entity has a reference to `Customer`. As the customer can be of the different types, when users create orders, they should be able to choose the type of the customer.\n\n## Implementation Details\n\nIn the `Customer` entity:\n\n* Inheritance strategy is set to `JOINED`\n* Discriminator column name `DTYPE` and type `String` are left default\n* Discriminator value is set to `C`\n\nIn the `Company` entity:\n\n* Parent class is set to `Customer`\n* Discriminator value is set to `M`\n\nIn the `Person` entity:\n\n* Parent class is set to `Customer`\n* Discriminator value is set to `P`\n\nThe `order-edit.xml` screen descriptor and the corresponding `OrderEdit` controller contain the customer selection components and logic.\n\nThe `customer-browse.xml` screen descriptor and the corresponding `CustomerBrowse` controller contains different `CreateAction`s for different types of customers. These actions are used in a popup button and as a context menu items in the table.\n\n## How to Run\n\nTo see the example in action, do the following:\n\n* Open the project in Studio\n* Click *Run \u003e Start application server*\n* If you see the warning *Database does not exist ...*, click *Create DB in background*\n* Go to `http://localhost:8080/app` and log in as `admin` / `admin`\n* Open *Application \u003e Orders* and create a new order.\n\nBased on CUBA Platform 6.9.4\n\n## Issues\nPlease use https://www.cuba-platform.com/discuss for discussion, support, and reporting problems coressponding to this sample.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcuba-platform%2Fsample-entity-inheritance","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcuba-platform%2Fsample-entity-inheritance","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcuba-platform%2Fsample-entity-inheritance/lists"}