1

我有一个这样的映射超类:

@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 {....

我在命名查询上收到“抽象架构类型'用户'未知”错误。我不明白为什么......名称用户是对的?

欢迎大家提出意见。

4

1 回答 1

2

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

于 2013-02-08T13:57:15.680 回答