OPENJPA-1047: Prohibit Table annotation or XML descriptor element for MappedSuperclass.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@835292 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Pinaki Poddar 2009-11-12 08:10:05 +00:00
parent 965c997c24
commit 8c952771dc
2 changed files with 9 additions and 3 deletions

View File

@ -62,6 +62,7 @@ import org.apache.openjpa.meta.ValueMetaData;
import org.apache.openjpa.persistence.XMLPersistenceMetaDataParser;
import org.apache.openjpa.util.InternalException;
import org.apache.openjpa.util.MetaDataException;
import org.apache.openjpa.util.UserException;
import org.xml.sax.Attributes;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
@ -781,11 +782,13 @@ public class XMLPersistenceMappingParser
*/
private boolean startTable(Attributes attrs)
throws SAXException {
ClassMapping mapping = (ClassMapping) currentElement();
if (mapping.isAbstract())
throw new UserException(_loc.get("table-not-allowed", mapping));
String table = toTableName(attrs.getValue("schema"),
attrs.getValue("name"));
if (table != null)
((ClassMapping) currentElement()).getMappingInfo().setTableName
(table);
mapping.getMappingInfo().setTableName(table);
return true;
}

View File

@ -60,3 +60,6 @@ implicit-non-default-fk: While parsing "{0}" from "{1}", found a @ForeignKey \
with implicit attribute set to true but one or more other attributes of \
ForeignKey is set to their non-default value. You can not specify any \
non-default value for an implicit ForeignKey.
table-not-allowed: You have specified Table annotation or XML descriptor element \
for MappedSuperclass "{0}". A class designated as a mapped superclass can not \
have a separate table defined for it.