如何在生成Hibernate的表中重命名字段名?当您创建:
@ManyToMany(targetEntity = GroupRightEntity.class)
or
@ManyToMany(targetEntity = UserRightEntity.class)现在,通过显式更改数据库中的列名来实现。
alter table security_mapping_user rename column sec_mapping_id to secmappingentity_id;谢谢你的帮助和理解。
Hibernate为其他表生成链接。因此,我理解生成的字段名。我需要使用注释,或者其他什么的,这些列名会改变。我希望我写的都是对的。
我们有。
@Entity
@Table(name = "ROLE")
public class RoleEntity implements Role, Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(generator = "SEQ_ROLE")
@SequenceGenerator(name = "SEQ_ROLE", sequenceName="SEQ_ROLE", allocationSize = 1)
private Long id;
private String name;
private String description;
@Entity
@Table(name = "URL")
public class UrlEntity implements Url, Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(generator = "SEQ_URL")
@SequenceGenerator(name="SEQ_URL", sequenceName="SEQ_URL", allocationSize = 1)
private Long id;
private String url;
@OneToMany(targetEntity = RoleEntity.class, fetch = FetchType.EAGER, mappedBy="url_id")
private Set<Role> roles;后来我们得到了第三张桌子。"URL_ROLE“
在这个表中,字段被命名为。"URL_ID“和"ROLE_ID”
"URL_ID“需要在"urlentity_id”中重命名该字段。
现在看来我把一切都做对了。
发布于 2013-01-14 15:02:48
在定义ManyToMany时,还应该定义关系映射的列。那就是你应该改名字的地方。
https://stackoverflow.com/questions/14319888
复制相似问题