我正在尝试为belos提供表结构的实体
(id, name, task, leader_id)
此表提供有关特定任务的团队用户及其团队负责人的信息。
我写了这样的实体
@Column(name = "id", insertable = false, nullable = false, updatable = true)
private Integer id;
@Col umn(name = "name", nullable = false)
private String tokenName;
@Column(name = "task", nullable = false)
private String task;
@ManyToOne(cascade = ALL, fetch = LAZY)
@JoinColumn(name = "leader_id")
private User leader;
我通过hibernate3:hbm2ddl创建了ddl,它看起来像这样
alter table user
drop
foreign key FK60FD5D6395C4EEC2;
drop table if exists user;
create table user (
id integer not null auto_increment,
task varchar(255),
name varchar(255) not null,
leader_id integer,
primary key (id)
);
alter table user
add index FK60FD5D6395C4EEC2 (leader_id),
add constraint FK60FD5D6395C4EEC2
foreign key (leader_id)
references user (id);
通过maven-sql-plugin导出此架构时,我收到以下错误
[ERROR] Failed to execute:
alter table user
drop
foreign key FK60FD5D6395C4EEC2
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Column "FOREIGN" not found; SQL statement:
alter table user
drop
foreign key FK60FD5D6395C4EEC2 [42122-158]
我做错了什么?
答案 0 :(得分:1)
试试这个:
@ManyToOne(cascade = ALL, fetch = LAZY)
@JoinColumn(name = "leader_id")
@NotFound(action = NotFoundAction.IGNORE)
public User getLeader()
{
return leader;
}