Hello
I am implementing a material list. Which means that I do have kind of a tree structure like in the composite pattern.
I have Material which may be a part or a parset whilst a partset may consist out of parts or other partsets (tree structure)
I do want TABLE_PER_CLASS strategy, so there should only be a table for part and partset, not material.
My code looks like this:
Code:
@Table(name = "Materialhierarchie")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@DiscriminatorColumn(name = "DISCRIMINATOR", discriminatorType = DiscriminatorType.STRING)
public abstract class Material {
}
@DiscriminatorValue("Part")
public class Part extends Material {
}
@DiscriminatorValue("Partset")
public class Partset extends Material {
private List<Material> materials = new ArrayList<Material>();
}
I am wondering if this is the proper way to to this.
In my database a partset_materials table gets created, but I am not able to open it due to the error: "artset_materials`: table data is not editable because there is no primary key defined for the table"
BTW: I am working with spring roo...
Any suggestions? I really would appreciate any help!
Thanks in advance
Alex