How to alter Column name in hibernate entity?

醉酒当歌 提交于 2019-12-10 11:38:57

问题


I have the following hibernate entity:

@Table(name="tbl_template")
@Entity
@Audited
public class StatementTemplate {
    private Long id;
    @Column(name = "template_name")
    private String templateName;
    ...

}

I changed the column name from template_name to stmt_name

@Column(name = "stmt_name")
private String templateName;

It turned out that the instead of changing the column name hibernate added another column named stmt_name, now I have template_name as well as stmt_name

I have following hibernate properties set up

<prop key="hibernate.hbm2ddl.auto">update</prop>

How can I get the column altered from template_name to stmt_name?


回答1:


Stopping your app, running ALTER TABLE, and starting the app again?



来源:https://stackoverflow.com/questions/8695019/how-to-alter-column-name-in-hibernate-entity

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