Enterprise application lookup values

I work for a company in the US who are considering adopting the CUBA Platform for our enterprise application development. We like what we’ve seen so far but one of our considerations currently is our legacy platform allowed our clients to modify lookup values that we ship with at run-time. Our application can have hundreds of lookup types. From what I’ve seen, CUBA provides Enum types but these wouldn’t be editable at run-time. Would our only answer that is supported in all areas of the app (REST API, Bulk Update, etc) be to create lookup tables for each or is there another approach that you’d recommend?

Hi,

as you said, Enums require code changes and are therefore not really suitable for this kind of requirement. The easiest way is to create a entity for every lookup type. This can either mean that you end up with hundreds of tables. But you can also use single table inheritance for that case, which eliminates the need to have explicit tables for the different lookup types.

I created an example for this (you will find it in the attachment), where you have different lookup types (Country, CustomerType, PaymentMethod) that extend the ReferenceType class. They use one single table (which means that they have pretty much the same attributes). In the reference from the business entity (Customer) i reference the concrete classes (Country instead of ReferenceType) which leads to the situation that there is an implicit filter on the DTYPE column that will pull only the correct data elements from the table.

With this all parts of CUBA should be able to handle these references correctly.

I wrote a blog post about reference types in general a while ago: https://www.road-to-cuba-and-beyond.com/how-to-deal-with-reference-data/ - you might want to have a look at it.

Bye
Mario

cuba-example-lookup-type-inheritance.zip (53.8K)

1 Like

Thanks Mario! That was helpful.