Details
-
Type:
Improvement
-
Status:
Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: 2.0-ALPHA4
-
Fix Version/s: 2.0
-
Component/s: Documentation
-
Security Level: All
-
Labels:None
Description
@MappedSuperclass
An mapped superclass is an abstract or concrete class that provides persistent entity state and mapping information for its subclasses, but which is not itself an entity. This annotation is specified on the Class docblock and has no additional attributes.
This doesn't adequately communicate how to use it. It took me several minutes of failing before I downloaded the PDF and did a search for @MappedSuperclass to find an example of how it's used.
Specifically the following were unclear:
- Is this defined on the superclass or on the children classes?
- If it's defined on the child classes, does it take parameters? The name of the super class?
- It was not at all apparent to me that it was mutually exclusive with the @Entity tag
Apparently it's also incompatible with several other tag as well.
I thought it made sense to try the following and see if the @InheritanceType and @Discriminator___ tags would apply to the children classes:
/** * @MappedSuperclass * @InheritanceType("SINGLE_TABLE") * @DiscriminatorColumn(name="type", type="string") * @DiscriminatorMap({"User" = "User", "Group" = "Group"}) */ abstract class PrincipalBut apparently this flags D2 to treat it as an Entity anyway, resulting in the following error: