Darth Blue Ray
Darth Blue Ray

Reputation: 9745

Mappedsuperclass and namedqueries

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.

Upvotes: 1

Views: 1345

Answers (1)

kostja
kostja

Reputation: 61558

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 @MappedSuperclass to @Entity.

Upvotes: 2

Related Questions