inheritance - Hibernate omit table when extended class contains only embeded collection -


i using @ moment inheritence strategy inheritancetype.joined. extended class contains map of type string stored in own table. wonder if there possibility omit table extended class contains id.

please let me know how model differently if there exist no direct option "omit" table.

the example shows have base class "attribute" extended class "stringmapattribute". extendend class contains collection. table "stringmapattribute" contains in end "id" "design overhead" can use inheritace , model different attribute types. therefore not ideal have table 1 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 embedded map  @entity @table(name="attribute_string") --> not keep 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 helpful hints.

yes comment "duncankinnear"is correct switched single_table strategy.

yes, disadvantage of joined strategy must have separate table each class, , stringmapattribute class doesn't make sense there no columns in table (apart id). need consider using single_table strategy. modern relational databases can store sparse-column tables (many null columns) efficiently bunch of separate tables, , don't have performance hit of having join tables together. – duncankinnear


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -