I know that the relational data model doesn’t allow us to do something like that but I have to find a way out.
Let’s say I try to create a spare part shop, and can sell parts themselves and assembled ones. I want to create an entity SparePart (let’s say ‘engine’) that contains a list of other SparePart’s. No problem with data model, I create an entity SparePartsList and everything goes fine. The problem is in creating views and screens for editors. Obviously.
I’m stuck on creating a list. I don’t want to create a separate ListEditor screen, I want to be able to see the list of inner parts (if list is not null) and to add more parts to the list right from the view SparePartEditor.
I guess my question is so complex that it needed a full guide, that’s why I’m sorry for asking it in that way.
The problem is not so obvious, at least for me. For example, in your SparePart entity you can make a reference to itself and show it in a Tree or TreeTable. Can you explain in more detail what do you want to achive, better with UI sketches?
I create an entity SparePart. But how to “say” that it can contain a ListOfSpareParts? If I create an association attribute “ListOfParts” of type SparePart with cardinality one_to_many it requires a “Mapped by” field which I can’t fill cos I don’t have any. M_2_m fires an error in DB creation.
If I create a list of entities as a separate entity in a data model than I have a problem working with views. And getting needed values to the needed fields. See the included file (sorry for handwriting)
And as I create an entity with code, I can’t see it on a screen even if I add it to a view…
Sorry for that lot of comments, but I’m trying options, and they don’t work properly… yet
In order to create an association with self, first create and save the entity without this association. Then edit the entity again and you will be able to select the same entity in the Type dropdown.
If you still have problems with displaying your data structure, please create a small test project with your data model and screens (even if they are not working as expected) and explain in details what do you need with relation to this test project.
Yes, first create the “parent” attribute which is a ManyToOne association. Then you will be able to use it as a mappedBy attribute when creating OneToMany collection.
Thanks for helping me creating the folded item. But i still can’t understand how to make inner entities visible on browse-edit screens. Can you, please point me to the place in user-manual, where i can find information about it. I attach my progress about the issue so far… Thanks in advance.
You can easily display hierarchical structures in a TreeTable - see the project attached.
In order to set the parent entity to the currently selected item, add the following to the browser screen:
First of all, thank you for your job. but now as i open an entity editor screen - it throws an exception that IndirectList cannot be cast to Entity. i guess i have to make additional field on an edit screen, that should hold a list, and somehow convert list to string?