【问题标题】:Can Nested or Inner class by an @Entity in JPA?JPA中的@Entity可以嵌套或内部类吗?
【发布时间】:2015-05-22 09:41:29
【问题描述】:

我可以并且应该将嵌套的内部类设为@Entity 吗?例如:

@Entity
public class EnclosingOne {
  @Entity
  public class NestedOne extends EnclosingOne {
  }
  @Entity
  public static class InnerOne extends EnclosingOne {
  }
}

或者:

public class EnclosingOne {
  @Entity
  public class NestedOne extends EnclosingOne {
  }
  @Entity
  public static class InnerOne extends EnclosingOne {
  }
}

【问题讨论】:

    标签: nested jpa-2.0


    【解决方案1】:

    JPA 2.1 规范,第 2.1 段,第 23 页,说:

    实体类必须是顶级类。

    【讨论】:

    • 不幸的是 :(。感谢您的回答。我想确定一下,因为 eclipse 没有指出这是一个错误。
    猜你喜欢
    • 2013-05-01
    • 2011-01-14
    • 1970-01-01
    • 1970-01-01
    • 2014-12-04
    • 1970-01-01
    • 2021-11-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多