I have a mappedsuperclass like this :
@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 {....
I get a “The abstract schema type ‘User’ is unknown” error on the namedquery. I don’t understand why … the name User is right?
Any suggestions would be welcome.
This is the expected JPA behaviour. Mapped superclasses are not queryable (see JPA 2.0 spec, section
2.11.2). If you want to make a superclass queryable, change the annotation from
@MappedSuperclassto@Entity.