带JPA +循环引用的继承抽象类

时间:2015-12-18 20:58:34

标签: java eclipse jpa inherited

我有一个抽象类AbstractEntity,它包含两个字段:

  • lastEditTime(LocalDateTime)
  • lastEditUser(UserEntity)

以下是代码:

@MappedSuperclass
public abstract class AbstractEntity {

    protected LocalDateTime lastEditTime;

    protected UserEntity lastEditUser;

    protected AbstractEntity () { }

    protected AbstractEntity (UserEntity creatorUser) {
        lastEditTime = LocalDateTime.now();
        lastEditUser = creatorUser;
    }

    public LocalDateTime getLastEditTime() {
        return lastEditTime;
    }

    public void setLastEditTime(LocalDateTime lastEditTime) {
        this.lastEditTime = lastEditTime;
    }

    public UserEntity getLastEditUser() {
        return lastEditUser;
    }

    public void setLastEditUser(UserEntity lastEditUser) {
        this.lastEditUser = lastEditUser;
    }
}

然后我有UserEntity类,它有许多不同的字段:

@Entity
@Table(name = "Users")
public class UserEntity extends AbstractEntity {

    @Id
    private String name;

    private String password;

    ...

}

Eclipse显示以下错误消息:

  

隐含关联覆盖" lastEditUser",加入列" lastEditUser_name"无法在桌面"用户"

这是什么意思?我该如何解决?

谢谢!

1 个答案:

答案 0 :(得分:0)

我断开了eclipse数据源。然后我清理项目(错误消息消失了),然后我删除了数据库中的表,最后我运行了一个测试用例来重新创建表。

新表有两个继承的列。