我有一个像这样的mappedsuperclass:
@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上的抽象模式类型'User'未知” 错误。我不明白为什么......用户的名字是对的?
欢迎任何建议。
答案 0 :(得分:2)
这是预期的JPA行为。映射的超类不可查询(参见JPA 2.0规范,部分
2.11.2)。如果要创建可查询的超类,请将注释从@MappedSuperclass
更改为@Entity
。