Iterator idColumnsIt = referencedEntity.getKey().getColumnIterator(); while ( idColumnsIt.hasNext() ) { idColumns.add( (Column) idColumnsIt.next() ); if ( columnOwner == null ) { try { throw new MappingException( "Unable to find column with logical name: " + columns[0].getReferencedColumn() + " in " + referencedEntity.getTable() + " and its related " + "supertables and secondary tables" ); throw new RecoverableException( e.getMessage(), e ); ( (PersistentClass) columnOwner ).getTable() : ( (Join) columnOwner ).getTable(); throw new MappingException( "Unable to find column with logical name: " + logicalReferencedColumnName + " in " + matchingTable.getName() ); Column refCol = new Column( referencedColumnName ); boolean contains = idColumns.contains( refCol ); if ( !contains ) {
prop.setOptional( optional ); if ( BinderHelper.isEmptyAnnotationValue( mappedBy ) ) { try { if ( otherSide == null ) { throw new MappingException( "Unable to find entity: " + value.getReferencedEntityName() ); ); if ( otherSideProperty.getValue() instanceof OneToOne ) { propertyHolder.addProperty( prop, inferredData.getDeclaringClass() ); else if ( otherSideProperty.getValue() instanceof ManyToOne ) { Iterator it = otherSide.getJoinIterator(); Join otherSideJoin = null; while ( it.hasNext() ) { referencesDerivedId = otherSide.getIdentifier() instanceof Component && ( (Component) otherSide.getIdentifier() ).getProperty( mappedBy ) != null;
throw new MappingException( "Discriminator formulas on joined inheritance hierarchies not supported at this time" ); explicitDiscriminatorColumnName = column.getQuotedName( factory.getDialect() ); discriminatorAlias = column.getAlias( factory.getDialect(), persistentClass.getRootTable() ); throw new MappingException("Illegal discriminator type: " + discriminatorType.getName() ); throw new MappingException("Could not format discriminator value to SQL string", e); throw new MappingException( "Could not format discriminator value to SQL string", e ); throw new MappingException( "optimistic-lock=all|dirty not supported for joined-subclass mappings [" + getEntityName() + "]" ); keyColumnReaders.add( keyColReaders ); keyColumnReaderTemplates.add( keyColReaderTemplates ); cascadeDeletes.add( key.isCascadeDeleteEnabled() && factory.getDialect().supportsCascadeDelete() ); int joinIdColumnSpan = key.getColumnSpan(); propTableNumbers.add( tabnum ); throw new MappingException( "Illegal discriminator type: " + discriminatorType.getName() ); throw new MappingException( "Could not format discriminator value to SQL string", e); throw new MappingException( "Error parsing discriminator value", e );
deleteResultCheckStyles = new ExecuteUpdateResultCheckStyle[joinSpan]; customSQLInsert[0] = persistentClass.getCustomSQLInsert(); : join.getCustomSQLDeleteCheckStyle(); while ( iter.hasNext() ) { Column col = (Column) iter.next(); keyCols[i++] = col.getQuotedName( factory.getDialect() ); throw new MappingException( "discriminator mapping required for single table polymorphic persistence" ); discriminatorColumnName = column.getQuotedName( factory.getDialect() ); throw new MappingException( "Illegal discriminator type: " + discriminatorType.getName() ); throw new MappingException( "Could not format discriminator value to SQL string", e ); prop.getPersistentClass().getEntityName() + '.' + prop.getName(), join ); throw new MappingException( "Illegal discriminator type: " + discriminatorType.getName() ); throw new MappingException( "Error parsing discriminator value", e );
this.sessionFactory = sessionFactory; name = persistentClass.getEntityName(); rootName = persistentClass.getRootClass().getEntityName(); ); versioned = persistentClass.isVersioned(); if ( persistentClass.hasPojoRepresentation() ) { if ( "id".equals( prop.getName() ) ) { foundNonIdentifierPropertyNamedId = true; nonlazyPropertyUpdateability[i] = properties[i].isUpdateable() && !lazy; propertyCheckability[i] = propertyUpdateability[i] || ( propertyTypes[i].isAssociationType() && ( (AssociationType) propertyTypes[i] ).isAlwaysDirtyChecked() ); if ( propertyTypes[i].isMutable() && propertyCheckability[i] ) { foundMutable = true; || optimisticLockStyle == OptimisticLockStyle.DIRTY; if ( isAllOrDirty && !dynamicUpdate ) { throw new MappingException( "optimistic-lock=all|dirty requires dynamic-update=\"true\": " + name ); throw new MappingException( "version and optimistic-lock=all|dirty are not a valid combination : " + name );
Set<ForeignKey> done, final MetadataBuildingContext buildingContext) throws MappingException { table.createForeignKeys(); Iterator itr = table.getForeignKeyIterator(); while ( itr.hasNext() ) { final ForeignKey fk = (ForeignKey) itr.next(); final String referencedEntityName = fk.getReferencedEntityName(); if ( referencedEntityName == null ) { throw new MappingException( "An association from the table " + fk.getTable().getName() + " does not specify the referenced entity" ); final PersistentClass referencedClass = getEntityBinding( referencedEntityName ); if ( referencedClass == null ) { throw new MappingException( "An association from the table " + fk.getTable().getName() + ); if ( referencedClass.isJoinedSubclass() ) { secondPassCompileForeignKeys( referencedClass.getSuperclass().getTable(), done, buildingContext );
private void alignColumns(Table referencedTable) { final int referencedPkColumnSpan = referencedTable.getPrimaryKey().getColumnSpan(); if ( referencedPkColumnSpan != getColumnSpan() ) { StringBuilder sb = new StringBuilder(); sb.append( "Foreign key (" ).append( getName() ).append( ":" ) .append( getTable().getName() ) .append( " [" ); appendColumns( sb, getColumnIterator() ); sb.append( "])" ) .append( ") must have same number of columns as the referenced primary key (" ) .append( referencedTable.getName() ) .append( " [" ); appendColumns( sb, referencedTable.getPrimaryKey().getColumnIterator() ); sb.append( "])" ); throw new MappingException( sb.toString() ); } Iterator fkCols = getColumnIterator(); Iterator pkCols = referencedTable.getPrimaryKey().getColumnIterator(); while ( pkCols.hasNext() ) { ( (Column) fkCols.next() ).setLength( ( (Column) pkCols.next() ).getLength() ); } }
Class mappedClass = persistentClass.getMappedClass(); Class proxyInterface = persistentClass.getProxyInterface(); throw new MappingException( "proxy must be either an interface, or the class itself: " + getEntityName() ); Iterator<Subclass> subclasses = persistentClass.getSubclassIterator(); while ( subclasses.hasNext() ) { final Subclass subclass = subclasses.next(); if ( subclassProxy != null && !subclassClass.equals( subclassProxy ) ) { if ( !subclassProxy.isInterface() ) { throw new MappingException( "proxy must be either an interface, or the class itself: " + subclass.getEntityName() ); while ( properties.hasNext() ) { Property property = (Property) properties.next(); Method method = property.getGetter( clazz ).getMethod(); if ( method != null && Modifier.isFinal( method.getModifiers() ) ) { LOG.gettersOfLazyClassesCannotBeFinal( persistentClass.getEntityName(), property.getName() ); method = property.getSetter( clazz ).getMethod(); if ( method != null && Modifier.isFinal( method.getModifiers() ) ) { LOG.settersOfLazyClassesCannotBeFinal( persistentClass.getEntityName(), property.getName() );
throw new MappingException( "Cannot use identity column key generation with <union-subclass> mapping for: " + getEntityName() tableName = determineTableName( persistentClass.getTable(), jdbcEnvironment ); boolean callable = false; ExecuteUpdateResultCheckStyle checkStyle = null; sql = persistentClass.getCustomSQLInsert(); callable = sql != null && persistentClass.isCustomInsertCallable(); checkStyle = sql == null ? ExecuteUpdateResultCheckStyle.COUNT while ( iter.hasNext() ) { Table tab = (Table) iter.next(); if ( !tab.isAbstractUnionTable() ) { final String tableName = determineTableName( tab, jdbcEnvironment ); tableNames.add( tableName ); String[] key = new String[idColumnSpan]; Iterator citer = tab.getPrimaryKey().getColumnIterator(); for ( int k = 0; k < idColumnSpan; k++ ) { key[k] = ( (Column) citer.next() ).getQuotedName( factory.getDialect() );
while( iterator.hasNext() ) { Element element = (Element) iterator.next(); Column column = new Column(); column.setName( element.attributeValue("name") ); String attributeValue = element.attributeValue("jdbc-type"); if(StringHelper.isNotEmpty(attributeValue)) { column.setSqlTypeCode(new Integer(JDBCToHibernateTypeHelper.getJDBCType(attributeValue))); if(table.getColumn(column)!=null) { throw new MappingException("Column " + column.getName() + " already exists in table " + tableIdentifier ); table.addColumn(column); columnNames.add(column.getName()); repository.setTypeNameForColumn(tableIdentifier, column.getName(), element.attributeValue("type")); List<Column> foreignColumns = new ArrayList<Column>(); Table foreignTable = new Table(); foreignTable.setName(foreignTableName); foreignTable.setCatalog(getValue(element.attributeValue( "foreign-catalog"),table.getCatalog()) ); throw new MappingException("foreign-column is required when foreign-table is specified on " + column);
public void validate(Mapping mapping) throws MappingException { Iterator iter = getPropertyIterator(); while ( iter.hasNext() ) { Property prop = (Property) iter.next(); if ( !prop.isValid( mapping ) ) { throw new MappingException( "property mapping has wrong number of columns: " + StringHelper.qualify( getEntityName(), prop.getName() ) + " type: " + prop.getType().getName() ); } } checkPropertyDuplication(); checkColumnDuplication(); }
throw new MappingException( String.format("Association [%s] for entity [%s] references unmapped class [%s]", propertyName, propertyHolder.getClassName(), assocClass) LOG.debugf( "Mapping collection: %s -> %s", collection.getRole(), collection.getCollectionTable().getName() ); && !collection.getKey().isNullable() ) { prop.setSelectable( false ); prop.setCollectionRole( collection.getRole() ); prop.setEntityName( collection.getOwner().getEntityName() ); prop.setValue( collection.getKey() ); referenced.addProperty( prop );
final String element = (String) st.nextElement(); if ( property == null ) { Property identifierProperty = getIdentifierProperty(); if ( identifierProperty != null && identifierProperty.getName().equals( element ) ) { else if ( identifierProperty == null && getIdentifierMapper() != null ) { identifierProperty = getProperty( element, getIdentifierMapper().getPropertyIterator() ); if ( identifierProperty != null ) { property = ( (Component) property.getValue() ).getProperty( element ); throw new MappingException( "property [" + propertyPath + "] not found on entity [" + getEntityName() + "]" );
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() ); } }
Selectable column = columns.get(i); if (column instanceof Column){ columnsNames[i] = ((Column) column).getName(); ), annotations, table.getCatalog(), table.getSchema(), table.getName(), Boolean.valueOf( typeParameters.getProperty( DynamicParameterizedType.IS_PRIMARY_KEY ) ), columnsNames throw new MappingException( "Could not create DynamicParameterizedType for type: " + typeName, e );
keyColumnNames[k] = col.getQuotedName( dialect ); keyColumnAliases[k] = col.getAlias( dialect, table ); k++; if ( elementType.isEntityType() ) { String entityName = ( (EntityType) elementType ).getAssociatedEntityName(); elementPersister = factory.getEntityPersister( entityName ); elementColumnNames[j] = col.getQuotedName( dialect ); elementColumnWriters[j] = col.getWriteExpr(); elementColumnReaders[j] = col.getReadExpr( dialect ); if ( hasIdentifier ) { if ( collectionBinding.isOneToMany() ) { throw new MappingException( "one-to-many collections with identifiers are not supported" ); if ( elementType.isComponentType() ) { elementPropertyMapping = new CompositeElementPropertyMapping( elementColumnNames, ); else if ( !elementType.isEntityType() ) { elementPropertyMapping = new ElementPropertyMapping( elementColumnNames,
if (persistentClass.getClassName() != null) { XClass clazz; try { clazz = reflectionManager.classForName( persistentClass.getClassName() ); throw new MappingException( e ); if ( revisionEntity != null ) { if (revisionEntityFound) { throw new MappingException("Only one entity may be annotated with @RevisionEntity!"); throw new MappingException("An entity annotated with @RevisionEntity cannot be audited!"); throw new MappingException( "An entity annotated with @RevisionEntity must have a field annotated " + "with @RevisionNumber!" throw new MappingException( "An entity annotated with @RevisionEntity must have a field annotated " + "with @RevisionTimestamp!" revisionInfoEntityName = persistentClass.getEntityName(); revisionInfoClass = persistentClass.getMappedClass(); final Class<? extends RevisionListener> revisionListenerClass = getRevisionListenerClass( revisionEntity.value() ); revisionInfoTimestampType = persistentClass.getProperty( revisionInfoTimestampData.getName() ).getType(); if ( globalCfg.isTrackEntitiesChangedInRevision() || ( globalCfg.isUseRevisionEntityWithNativeId() && DefaultTrackingModifiedEntitiesRevisionEntity.class
@Override public org.hibernate.type.Type getIdentifierType(String entityName) throws MappingException { final PersistentClass pc = entityBindingMap.get( entityName ); if ( pc == null ) { throw new MappingException( "persistent class not known: " + entityName ); } return pc.getIdentifier().getType(); }
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() ); } } }
@Override public String getPhysicalColumnName(Table table, Identifier logicalName) throws MappingException { if ( logicalName == null ) { throw new MappingException( "Logical column name cannot be null" ); } Table currentTable = table; String physicalName = null; while ( currentTable != null ) { final TableColumnNameBinding binding = columnNameBindingByTableMap.get( currentTable ); if ( binding != null ) { physicalName = binding.logicalToPhysical.get( logicalName ); if ( physicalName != null ) { break; } } if ( DenormalizedTable.class.isInstance( currentTable ) ) { currentTable = ( (DenormalizedTable) currentTable ).getIncludedTable(); } else { currentTable = null; } } if ( physicalName == null ) { throw new MappingException( "Unable to find column with logical name " + logicalName.render() + " in table " + table.getName() ); } return physicalName; }