I use InheritanceType.TABLE_PER_CLASS. Somehow I can define the name of the child table, but not of the parent table.
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@Table(name="foo")
public class Parent {
...
}
@Entity
@Table(name="bar")
public class Child extends Parent {
...
}
Results in:
Schema | Name | Typ
--------+----------------
public | parent | Table
public | bar | Table
What am I doing wrong?
As usual, the problem was in front of the keyboard... me.
Solution for anyone having the same issue and don't want to waste as much time:
In the strategy
InheritanceType.TABLE_PER_CLASSthere is NO parent table. All attributes of the parent class are directly stored in the child tables. So, if there is no parent table, it can not be renamed!But why was it listed in my database? Before choosing
InheritanceType.TABLE_PER_CLASSI tried differed strategies likeInheritanceType.JOINEDwhich in deed creates a parent table. Using the propertyspring.jpa.hibernate.ddl-auto=createfor development, I assumed the database will always match my java implementation (https://stackoverflow.com/a/1689769/8345434). However,createonly drops data and not tables which are no longer part of the implementation. Thus, after each application restart I so the old table which was no langer part of the application.