Hibernate忽略扩展类的@Table(name =" ...") - 创建的表名都是小写的 [英] Hibernate ignores @Table(name = "...") for extended classes - created tablenames are all lower case
问题描述
我们通过Hibernate自动创建表格:
@Table(name =some_table)
曾用于普通实体。但是当我们有一个抽象基类时:
$ p $ @Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public class PersonBankAccount extends AbstractPersistable< Long> {b $ b
由
<$ p $ @Entity
@Table(name =person_bank_account)
public class PersonBankAccountSimple extends PersonBankAccount {
数据库中的结果表被命名为
personbankaccount
这是怎么回事?
autogenerator说: / p>
找不到表格:PersonBankAccount
当第一次创建它并重新运行时他说:
找到的表:personbankaccount
正如我所说的,对于普通表,一切正常。
不应该是基类中表的名字。
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@Table(name =person_bank_account)
public class PersonBankAccount e xtends AbstractPersistable< Long> {
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.
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> {
这篇关于Hibernate忽略扩展类的@Table(name =" ...") - 创建的表名都是小写的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!