Ah, I see something similar has been posted recently,
but without definitive answer:
http://n2.nabble.com/UniqueConstraint-in-a-MappedSuperclass-not-working-tc2633410.html
Seems not to be an entirely unreasonable use case,
given that Eclipselink and Hibernate support it (according
to the above posting).
--Martin Dirichs.
Martin Dirichs-2 wrote:
>
> 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.
>
>
--
View this message in context:
http://n2.nabble.com/Using-MappedSuperclass-with-UniqueConstraint-tp2727413p2727554.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.