Hi,

defining constraints on a mapped superclass does not
work with OpenJPA (tried with 2.0.0-snapshot, but I
guess it's the same with 1.x-releases).

Example:
@MappedSuperclass
@Table(uniqueConstraints = @UniqueConstraint(columnNames = "name"))
public abstract class NamedEntity {
    String name;
}

This leads to the following exception:
org.apache.openjpa.util.UserException: The column "name" in a
unique constraint in "NamedEntity" on table "null" can not be
found in the list of available columns "[]"
at
org.apache.openjpa.jdbc.meta.ClassMappingInfo.getUniques(ClassMappingInfo.java:433)

The JPA specification isn't explicit about how to handle
this case, so this may be correct behaviour depending on
the interpretation of the spec. I just thought it would be
convenient to be able to extract the unique constraint
mapping information in a superclass. After all, it is the
underlying idea of mapped superclasses to gather the
common properties of their derived classes, including
mapping information.

  Regards,
    Martin Dirichs.
-- 
  Martin Dirichs
  [email protected]

Reply via email to