Renaming Spring Data jpa Id column

自闭症网瘾萝莉.ら 提交于 2019-12-11 04:48:45

问题


From my entity I'm trying to rename the id column field defined in AbstractPersistable by Spring Data Jpa using AttributeOverride annotation.

@Entity
@AttributeOverride(name="id", column=@Column(name="user_id"))
public class User extends AbstractPersistable<Long>  {
...

this is failing with the exception

Caused by: org.hibernate.MappingException: Unable to find column with logical name: id in org.hibernate.mapping.Table(user) and its related supertables and secondary tables

the only time the above definition is passing and the DDL is generated is when I define the column name as ID like

@AttributeOverride(name="id", column=@Column(name="ID"))

Seems like a bug to me. I really don't get what the problem is.

来源:https://stackoverflow.com/questions/27316502/renaming-spring-data-jpa-id-column

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!