我有一个像这样的mappingsuperclass:

@MappedSuperclass
@DiscriminatorColumn(name = "USER_TYPE")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@NamedQueries({
        @NamedQuery(name = "selectAllUsers", query = "SELECT u FROM User u"),
        @NamedQuery(name = "deleteUserByName", query = "DELETE FROM User u WHERE u.userName like :name"),
        @NamedQuery(name = "getUserByName", query = "SELECT FROM User u WHERE u.userName like :name") })
public abstract class User implements Serializable {....


我在namedquery上收到“抽象模式类型'用户'未知”错误。我不明白为什么...用户名正确吗?

欢迎大家提出意见。

最佳答案

这是预期的JPA行为。映射的超类不可查询(请参阅JPA 2.0规范,第1部分)。
2.11.2)。如果要使超类可查询,请将注释从@MappedSuperclass更改为@Entity

10-05 23:24