Generic Relationships

Hi,

Django Project, to cite an example, has a feature called Generic Relations by which you can have one Entity (ie: Task) which has a foreign key to an undefined type (ie: Project, Case).

How could this be implemented in CUBA? (I’m on 7.0 beta)

There are two use cases I have in mind now:

  1. I have a Task Entity which has a root attribute which might point to either a Project, Account or some other Entities. Having a different Task for each possible link is crazy.
  2. I have a Document Entity which has a root attribute which might point to either Account, Case, TaxFiling, … pretty much any object can have documents attached.

What would be the CUBA way?

1 Like

Hi,

When you search for polymorphic associations here you will find some discussions around that. I implemented a solution for some of the stories you described. Take a look at:

As well as a concrete implementation for attachements:

Bye
Mario

2 Likes

Good!
Thank you @mario, I will use it as a reference!!

Do you plan on releasing an updated version for 7.0 of the soft-references-entities module?