I am using at the moment the inheritence strategy InheritanceType.JOINED. My extended class contains just a Map of type String which is stored in its own table. I wonder if there is a possibility to omit the table for my extended class which contains just the id.
Please let me know how you would model it differently if there exist no direct option to "omit" the table.
The example shows that I have a base class "Attribute" which get extended by a class "StringMapAttribute". This extendend class just contains a collection. The table for "StringMapAttribute" contains in the end just the "id" which is "Design Overhead" so I can use inheritace and model different attribute types. Therefore it is not ideal to have just a table with one single id column.
// Base class
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name="TYPE", discriminatorType=DiscriminatorType.STRING)
public abstract class Attribute<T> implements Serializable {
@Id
@GeneratedValue
private int id;
private String name;
...
}
// Extended class with embedded map
@Entity
@Table(name="attribute_string") --> I like not to keep that table
@DiscriminatorValue("STRING")
public class StringMapAttribute extends Attribute<Map<String,String>> {
@ElementCollection
@CollectionTable(name= "attribute_string_language", joinColumns = @JoinColumn(name = "attribute_id")
)
@MapKeyColumn(name="language")
@Column(name = "value")
private Map<String, String> value = new HashMap<String, String>();
}
Thank you for any helpful hints.
Yes the comment from "DuncanKinnear"is correct so I switched to SINGLE_TABLE strategy.