Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate ignores @Table(name = "...") for extended classes - created tablenames are all lower case

We create our tables automaticly via Hibernate by assigning:

@Table(name = "some_table") 

That used to work for "normal" entities. But when we have an abstract base class:

@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public class PersonBankAccount extends AbstractPersistable<Long> {

that is extended by

@Entity
@Table(name = "person_bank_account")
public class PersonBankAccountSimple extends PersonBankAccount {

The resulting table in the database is named

personbankaccount

What is going on here?

The autogenerator says:

table not found: PersonBankAccount 

when first creating it and on rerun he says:

table found: personbankaccount

Like I said, for normal tables everything works fine.

like image 264
Pete Avatar asked Dec 22 '11 14:12

Pete


1 Answers

Shouldn't be the name of table in the base class instead.

@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@Table(name = "person_bank_account")
public class PersonBankAccount extends AbstractPersistable<Long> {
like image 55
viktor Avatar answered Oct 29 '22 03:10

viktor