I have a few simple entities that are stored in a simple “code” table with the following structure (all stored as character fields):
code_fieldname pk
code_value pk
code_comment
code_field1
code_field2
One object I am trying to map has data stored in this table of the following form
code_fieldname = "segment"
class = Segment
segment.id = code_value
segment.name = code_comment
segment.markup = code_field1 (decimal property)
So the segment records all have a “code_fieldname” = “segment” with their ID being the value of “code_value”.
What is the mapping for such a structure? I am using XML based mapping.
I’ve managed to solve this first by using inheritance for the class, and then using a formula property on the relationship. Definition for the entities follow:
Now I can use this in a relationship like the following:
Note that the formula requires the quoted ‘segment’ value as this is always the fields key, i.e. code_fieldname = ‘segment’ in all cases.