【发布时间】:2014-10-21 00:23:21
【问题描述】:
我有一个名为 LocationType 的实体(BaseEntity 是 @MappedSuperclass):
@Entity
public class LocationType extends BaseEntity
为此实体生成的表名是location_type。我了解默认命名策略是这样的。
我无法理解为什么我不能强制 Hibernate 使用文字名称locationtype。不管我做什么:
@Entity(name = "LocationType")
public class LocationType
或
@Entity
@Table(name = "LocationType")
public class LocationType
或
@Entity(name = "LocationType")
@Table(name = "LocationType")
public class LocationType
表名always 以location_type 结尾。 Hibernate 知道得更好!
如果我使用任何其他名称
@Entity(name = "wtf")
那么表名也变成wtf。
这是记录在案的行为吗?对我来说似乎是一个错误。
类似问题:Hibernate ignores @Table(name = "...") for extended classes - created tablenames are all lower case(不过它指的是继承映射)。
【问题讨论】:
-
你使用的是什么版本的休眠?你还在使用hibernate注解还是javax.persistence注解?
-
如果我使用
javax.persistence.Entity,我看不到任何问题,您能否发布更多详细信息,例如 hibernate.cfg.xml 文件和您的超类等中的任何特定属性,以更好地理解问题。 -
@Entity 和@Table 都来自
javax.persistence。休眠版本是 4.3.1。