I have an entity Call containing an ItilStatus:
Code:
@Entity
public class Call {
@Id
private int id;
private ItilStatus itilStatus;
...
More fields
}
ItilStatus does not have its own table, but the possible values are found in a table with 5 columns:
Code:
----------------------------------------------------------------------
| table_name | column_name | column_type | enum_value | enum_label |
----------------------------------------------------------------------
The first four columns make up the compound primary key - so I have created a CompoundKey class:
Code:
@Embeddable
public class EnumCompoundKey implements Serializable {
private String tableName;
private String columnName;
private int columnType;
private int enumValue;
...
4-param contructor, getters, setters, hashCode() and equals()
}
However, for ItilStatus, the 3 first fields are always set to 'calls', 'itilstatus' and '14'.
How should this 'static' relationship be reflected in the ItilStatus class?
Code:
@Entity
public class ItilStatus {
@Id
private EnumCompoundKey id;
private String label;
public EnumCompoundKey getId() {
return id;
}
public void setId(EnumCompoundKey id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
}
Is my approach completely wrong?