In my domain model class Component has a list of properties as follows:
Code:
public class Component {
private List<Property> properties = new ArrayList<Property>();
}
public class Property {
private String name;
private Object value;
}
The property values are either Floats or Strings. Of course if I create direct mapping for the class Property I have to specify the class for value attribute (I cannot leave it simply as Object). The application uses a lot of searches made to these properties (e.g. find components with weight property < 100). The question is which would be the best way to model these domain objects. Regarding efficiency it probably would be best if I had properties with String values in their own table and Float values in their own table. However following is bit cumbersome:
Code:
public class Component {
private List<StringProperty> stringValueProperties = new ArrayList<StringProperty>();
private List<FloatProperty> floatValueProperties = new ArrayList<FloatProperty>();
}
public class StringProperty {
private String name;
private String value;
}
public class FloatProperty {
private String name;
private Float value;
}