public boolean isValid(Mapping mapping) throws MappingException { if ( referencedEntityName == null ) { throw new MappingException( "one to many association must specify the referenced entity" ); } return true; }
@Override public CollectionPersister collectionPersister(String role) { final CollectionPersister persister = collectionPersisterMap.get( role ); if ( persister == null ) { throw new MappingException( "Could not locate CollectionPersister for role : " + role ); } return persister; }
@Override public EntityPersister entityPersister(String entityName) throws MappingException { EntityPersister result = entityPersisterMap.get( entityName ); if ( result == null ) { throw new MappingException( "Unknown entity: " + entityName ); } return result; }
@Override public void configure(Type type, Properties params, ServiceRegistry serviceRegistry) throws MappingException { entityName = params.getProperty( ENTITY_NAME ); if ( entityName == null ) { throw new MappingException("no entity name"); } } }
public String[] getColumnNames(String propertyName) { String[] cols = columnsByPropertyPath.get( propertyName ); if ( cols == null ) { throw new MappingException( "unknown property: " + propertyName ); } return cols; }
void throwUnsupportedTypeException(Type type, String entityName, String propertyName) { final String message = "Type not supported for auditing: " + type.getClass().getName() + ", on entity " + entityName + ", property '" + propertyName + "'."; throw new MappingException( message ); }
public boolean isValid(Mapping mapping) throws MappingException { if (referencedEntityName==null) { throw new MappingException("association must specify the referenced entity"); } return super.isValid( mapping ); }
/** * Because of the overridden {@link #getCreateSequenceString(String)}, we must also override * {@link #getCreateSequenceString(String, int, int)} to prevent 2 instances of "start with". */ @Override protected String getCreateSequenceString(String sequenceName, int initialValue, int incrementSize) throws MappingException { if ( supportsPooledSequences() ) { return "create sequence " + sequenceName + " start with " + initialValue + " increment by " + incrementSize; } throw new MappingException( getClass().getName() + " does not support pooled sequences" ); }
@Override public String getSequenceNextValString(String sequenceName) { if ( supportsSequences() ) { return "values next value for " + sequenceName; } else { throw new MappingException( "Derby does not support sequence prior to release 10.6.1.0" ); } }
private SQLLoadable getSQLLoadable(String entityName) throws MappingException { EntityPersister persister = factory.getEntityPersister( entityName ); if ( !(persister instanceof SQLLoadable) ) { throw new MappingException( "class persister is not SQLLoadable: " + entityName ); } return (SQLLoadable) persister; }
private void checkPropertyDuplication() throws MappingException { HashSet<String> names = new HashSet<>(); Iterator iter = getPropertyIterator(); while ( iter.hasNext() ) { Property prop = (Property) iter.next(); if ( !names.add( prop.getName() ) ) { throw new MappingException( "Duplicate property mapping of " + prop.getName() + " found in " + getEntityName() ); } } }
public UniqueKey addUniqueKey(UniqueKey uniqueKey) { UniqueKey current = uniqueKeys.get( uniqueKey.getName() ); if ( current != null ) { throw new MappingException( "UniqueKey " + uniqueKey.getName() + " already exists!" ); } uniqueKeys.put( uniqueKey.getName(), uniqueKey ); return uniqueKey; }
@Override public String getIdentifierPropertyName(String entityName) throws MappingException { final PersistentClass pc = entityBindingMap.get( entityName ); if ( pc == null ) { throw new MappingException( "persistent class not known: " + entityName ); } if ( !pc.hasIdentifierProperty() ) { return null; } return pc.getIdentifierProperty().getName(); }
protected Type requireIdentifierOrUniqueKeyType(Mapping mapping) { final Type fkTargetType = getIdentifierOrUniqueKeyType( mapping ); if ( fkTargetType == null ) { throw new MappingException( "Unable to determine FK target Type for many-to-one or one-to-one mapping: " + "referenced-entity-name=[" + getAssociatedEntityName() + "], referenced-entity-attribute-name=[" + getLHSPropertyName() + "]" ); } return fkTargetType; } }
@Override public NativeQuery setResultSetMapping(String name) { ResultSetMappingDefinition mapping = getProducer().getFactory().getNamedQueryRepository().getResultSetMappingDefinition( name ); if ( mapping == null ) { throw new MappingException( "Unknown SqlResultSetMapping [" + name + "]" ); } NativeSQLQueryReturn[] returns = mapping.getQueryReturns(); queryReturns.addAll( Arrays.asList( returns ) ); return this; }
private OuterJoinLoadable getOuterJoinLoadable(String entityName) throws MappingException { EntityPersister persister = getFactory().getMetamodel().entityPersister( entityName ); if ( !( persister instanceof OuterJoinLoadable ) ) { throw new MappingException( "class persister is not OuterJoinLoadable: " + entityName ); } return (OuterJoinLoadable) persister; }
public Class getComponentClass() throws MappingException { final ClassLoaderService classLoaderService = getMetadata() .getMetadataBuildingOptions() .getServiceRegistry() .getService( ClassLoaderService.class ); try { return classLoaderService.classForName( componentClassName ); } catch (ClassLoadingException e) { throw new MappingException("component class not found: " + componentClassName, e); } }
public void validate(Mapping mapping) throws MappingException { super.validate(mapping); if ( key!=null && !key.isValid(mapping) ) { throw new MappingException( "subclass key mapping has wrong number of columns: " + getEntityName() + " type: " + key.getType().getName() ); } }
public void validate(Mapping mapping) throws MappingException { super.validate(mapping); if ( key!=null && !key.isValid(mapping) ) { throw new MappingException( "subclass key mapping has wrong number of columns: " + getEntityName() + " type: " + key.getType().getName() ); } }
public void validate(Mapping mapping) throws MappingException { super.validate( mapping ); assert getElement() != null : "IndexedCollection index not bound : " + getRole(); if ( !getIndex().isValid(mapping) ) { throw new MappingException( "collection index mapping has wrong number of columns: " + getRole() + " type: " + getIndex().getType().getName() ); } }