Java 类org.hibernate.engine.spi.Mapping 实例源码

项目:lams    文件:PersistentClass.java   
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();
}
项目:lams    文件:UnionSubclassEntityPersister.java   
public UnionSubclassEntityPersister(
        final EntityBinding entityBinding,
        final EntityRegionAccessStrategy cacheAccessStrategy,
        final NaturalIdRegionAccessStrategy naturalIdRegionAccessStrategy,
        final SessionFactoryImplementor factory,
        final Mapping mapping) throws HibernateException {
    super(entityBinding, cacheAccessStrategy, naturalIdRegionAccessStrategy, factory );
    // TODO: implement!!! initializing final fields to null to make compiler happy.
    subquery = null;
    tableName = null;
    subclassClosure = null;
    spaces = null;
    subclassSpaces = null;
    discriminatorValue = null;
    discriminatorSQLValue = null;
    constraintOrderedTableNames = null;
    constraintOrderedKeyColumnNames = null;
}
项目:lams    文件:JoinHelper.java   
/**
 * Get the qualified (prefixed by alias) names of the columns of the owning entity which are to be used in the join
 *
 * @param associationType The association type for the association that represents the join
 * @param columnQualifier The left-hand side table alias
 * @param propertyIndex The index of the property that represents the association/join
 * @param begin The index for any nested (composites) attributes
 * @param lhsPersister The persister for the left-hand side of the association/join
 * @param mapping The mapping (typically the SessionFactory).
 *
 * @return The qualified column names.
 */
public static String[] getAliasedLHSColumnNames(
        AssociationType associationType,
        String columnQualifier,
        int propertyIndex,
        int begin,
        OuterJoinLoadable lhsPersister,
        Mapping mapping) {
    if ( associationType.useLHSPrimaryKey() ) {
        return StringHelper.qualify( columnQualifier, lhsPersister.getIdentifierColumnNames() );
    }
    else {
        final String propertyName = associationType.getLHSPropertyName();
        if ( propertyName == null ) {
            return ArrayHelper.slice(
                    toColumns( lhsPersister, columnQualifier, propertyIndex ),
                    begin,
                    associationType.getColumnSpan( mapping )
            );
        }
        else {
            //bad cast
            return ( (PropertyMapping) lhsPersister ).toColumns( columnQualifier, propertyName );
        }
    }
}
项目:lams    文件:JoinedSubclass.java   
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()
            );
    }
}
项目:lams    文件:RootClass.java   
@Override
   public void validate(Mapping mapping) throws MappingException {
    super.validate(mapping);
    if ( !getIdentifier().isValid(mapping) ) {
        throw new MappingException(
            "identifier mapping has wrong number of columns: " +
            getEntityName() +
            " type: " +
            getIdentifier().getType().getName()
        );
    }
    checkCompositeIdentifier();
}
项目:lams    文件:Index.java   
public String sqlCreateString(Dialect dialect, Mapping mapping, String defaultCatalog, String defaultSchema)
        throws HibernateException {
    return buildSqlCreateIndexString(
            dialect,
            getName(),
            getTable(),
            getColumnIterator(),
            columnOrderMap,
            false,
            defaultCatalog,
            defaultSchema
    );
}
项目:lams    文件:Table.java   
public void validateColumns(Dialect dialect, Mapping mapping, TableMetadata tableInfo) {
    Iterator iter = getColumnIterator();
    while ( iter.hasNext() ) {
        Column col = (Column) iter.next();

        ColumnMetadata columnInfo = tableInfo.getColumnMetadata( col.getName() );

        if ( columnInfo == null ) {
            throw new HibernateException( "Missing column: " + col.getName() + " in " + Table.qualify( tableInfo.getCatalog(), tableInfo.getSchema(), tableInfo.getName()));
        }
        else {
            final boolean typesMatch = col.getSqlType( dialect, mapping ).toLowerCase()
                    .startsWith( columnInfo.getTypeName().toLowerCase() )
                    || columnInfo.getTypeCode() == col.getSqlTypeCode( mapping );
            if ( !typesMatch ) {
                throw new HibernateException(
                        "Wrong column type in " +
                        Table.qualify( tableInfo.getCatalog(), tableInfo.getSchema(), tableInfo.getName()) +
                        " for column " + col.getName() +
                        ". Found: " + columnInfo.getTypeName().toLowerCase() +
                        ", expected: " + col.getSqlType( dialect, mapping )
                );
            }
        }
    }

}
项目:lams    文件:PersistentClass.java   
public void prepareTemporaryTables(Mapping mapping, Dialect dialect) {
    temporaryIdTableName = dialect.generateTemporaryTableName( getTable().getName() );
    if ( dialect.supportsTemporaryTables() ) {
        Table table = new Table();
        table.setName( temporaryIdTableName );
        Iterator itr = getTable().getPrimaryKey().getColumnIterator();
        while( itr.hasNext() ) {
            Column column = (Column) itr.next();
            table.addColumn( column.clone()  );
        }
        temporaryIdTableDDL = table.sqlTemporaryTableCreateString( dialect, mapping );
    }
}
项目:lams    文件:UniqueKey.java   
@Override
   public String sqlCreateString(Dialect dialect, Mapping p,
        String defaultCatalog, String defaultSchema) {
    return dialect.getUniqueDelegate().getAlterTableToAddUniqueKeyCommand(
            this, defaultCatalog, defaultSchema
    );
}
项目:lams    文件:CompositeCustomType.java   
public int getColumnSpan(Mapping mapping) throws MappingException {
    Type[] types = userType.getPropertyTypes();
    int n=0;
    for ( Type type : types ) {
        n += type.getColumnSpan( mapping );
    }
    return n;
}
项目:lams    文件:AbstractEntityPersister.java   
private void initIdentifierPropertyPaths(Mapping mapping) throws MappingException {
    String idProp = getIdentifierPropertyName();
    if ( idProp != null ) {
        propertyMapping.initPropertyPaths( idProp, getIdentifierType(), getIdentifierColumnNames(),
                getIdentifierColumnReaders(), getIdentifierColumnReaderTemplates(), null, mapping );
    }
    if ( entityMetamodel.getIdentifierProperty().isEmbedded() ) {
        propertyMapping.initPropertyPaths( null, getIdentifierType(), getIdentifierColumnNames(),
                getIdentifierColumnReaders(), getIdentifierColumnReaderTemplates(), null, mapping );
    }
    if ( ! entityMetamodel.hasNonIdentifierPropertyNamedId() ) {
        propertyMapping.initPropertyPaths( ENTITY_ID, getIdentifierType(), getIdentifierColumnNames(),
                getIdentifierColumnReaders(), getIdentifierColumnReaderTemplates(), null, mapping );
    }
}
项目:lams    文件:AbstractEntityPersister.java   
private void initDiscriminatorPropertyPath(Mapping mapping) throws MappingException {
    propertyMapping.initPropertyPaths( ENTITY_CLASS,
            getDiscriminatorType(),
            new String[]{getDiscriminatorColumnName()},
            new String[]{getDiscriminatorColumnReaders()},
            new String[]{getDiscriminatorColumnReaderTemplate()},
            new String[]{getDiscriminatorFormulaTemplate()},
            getFactory() );
}
项目:lams    文件:EntityType.java   
/**
 * The name of the property on the associated entity to which our FK
 * refers
 *
 * @param factory The mappings...
 * @return The appropriate property name.
 * @throws MappingException Generally, if unable to resolve the associated entity name
 */
public final String getIdentifierOrUniqueKeyPropertyName(Mapping factory)
throws MappingException {
    if ( isReferenceToPrimaryKey() || uniqueKeyPropertyName == null ) {
        return factory.getIdentifierPropertyName( getAssociatedEntityName() );
    }
    else {
        return uniqueKeyPropertyName;
    }
}
项目:lams    文件:PersisterFactoryImpl.java   
@Override
@SuppressWarnings( {"unchecked"})
public EntityPersister createEntityPersister(
        PersistentClass metadata,
        EntityRegionAccessStrategy cacheAccessStrategy,
        NaturalIdRegionAccessStrategy naturalIdRegionAccessStrategy,
        SessionFactoryImplementor factory,
        Mapping cfg) {
    Class<? extends EntityPersister> persisterClass = metadata.getEntityPersisterClass();
    if ( persisterClass == null ) {
        persisterClass = serviceRegistry.getService( PersisterClassResolver.class ).getEntityPersisterClass( metadata );
    }
    return create( persisterClass, ENTITY_PERSISTER_CONSTRUCTOR_ARGS, metadata, cacheAccessStrategy, naturalIdRegionAccessStrategy, factory, cfg );
}
项目:lams    文件:CompositeElementPropertyMapping.java   
public CompositeElementPropertyMapping(
        String[] elementColumns,
        String[] elementColumnReaders,
        String[] elementColumnReaderTemplates, 
        String[] elementFormulaTemplates, 
        CompositeType compositeType,
        Mapping factory)
throws MappingException {

    this.compositeType = compositeType;

    initComponentPropertyPaths(null, compositeType, elementColumns, elementColumnReaders,
            elementColumnReaderTemplates, elementFormulaTemplates, factory);

}
项目:lams    文件:JoinHelper.java   
/**
 * Get the columns of the owning entity which are to be used in the join
 *
 * @param type The type representing the join
 * @param property The property index for the association type
 * @param begin ?
 * @param lhsPersister The persister for the left-hand-side of the join
 * @param mapping The mapping object (typically the SessionFactory)
 *
 * @return The columns for the left-hand-side of the join
 */
public static String[] getLHSColumnNames(
        AssociationType type,
        int property,
        int begin,
        OuterJoinLoadable lhsPersister,
        Mapping mapping) {
    if ( type.useLHSPrimaryKey() ) {
        //return lhsPersister.getSubclassPropertyColumnNames(property);
        return lhsPersister.getIdentifierColumnNames();
    }
    else {
        final String propertyName = type.getLHSPropertyName();
        if ( propertyName == null ) {
            //slice, to get the columns for this component
            //property
            return ArrayHelper.slice(
                    property < 0
                            ? lhsPersister.getIdentifierColumnNames()
                            : lhsPersister.getSubclassPropertyColumnNames( property ),
                    begin,
                    type.getColumnSpan( mapping )
            );
        }
        else {
            //property-refs for associations defined on a
            //component are not supported, so no need to slice
            return lhsPersister.getPropertyColumnNames( propertyName );
        }
    }
}
项目:lams    文件:StandardAnsiSqlAggregationFunctions.java   
protected final int determineJdbcTypeCode(Type type, Mapping mapping) throws QueryException {
    try {
        final int[] jdbcTypeCodes = type.sqlTypes( mapping );
        if ( jdbcTypeCodes.length != 1 ) {
            throw new QueryException( "multiple-column type in sum()" );
        }
        return jdbcTypeCodes[0];
    }
    catch ( MappingException me ) {
        throw new QueryException( me );
    }
}
项目:lams    文件:EntityType.java   
/**
 * Determine the type of either (1) the identifier if we reference the
 * associated entity's PK or (2) the unique key to which we refer (i.e.
 * the property-ref).
 *
 * @param factory The mappings...
 * @return The appropriate type.
 * @throws MappingException Generally, if unable to resolve the associated entity name
 * or unique key property name.
 */
public final Type getIdentifierOrUniqueKeyType(Mapping factory) throws MappingException {
    if ( isReferenceToPrimaryKey() || uniqueKeyPropertyName == null ) {
        return getIdentifierType(factory);
    }
    else {
        Type type = factory.getReferencedPropertyType( getAssociatedEntityName(), uniqueKeyPropertyName );
        if ( type.isEntityType() ) {
            type = ( ( EntityType ) type).getIdentifierOrUniqueKeyType( factory );
        }
        return type;
    }
}
项目:lams    文件:ManyToOneType.java   
public boolean[] toColumnNullness(Object value, Mapping mapping) {
    boolean[] result = new boolean[ getColumnSpan( mapping ) ];
    if ( value != null ) {
        Arrays.fill( result, true );
    }
    return result;
}
项目:lams    文件:EntityType.java   
@Override
public Object fromXMLNode(Node xml, Mapping factory) throws HibernateException {
    if ( !isEmbeddedInXML ) {
        return getIdentifierType(factory).fromXMLNode(xml, factory);
    }
    else {
        return xml;
    }
}
项目:lams    文件:ComponentType.java   
@Override
public int getColumnSpan(Mapping mapping) throws MappingException {
    int span = 0;
    for ( int i = 0; i < propertySpan; i++ ) {
        span += propertyTypes[i].getColumnSpan( mapping );
    }
    return span;
}
项目:lams    文件:ComponentType.java   
@Override
public Size[] dictatedSizes(Mapping mapping) throws MappingException {
    //Not called at runtime so doesn't matter if its slow :)
    final Size[] sizes = new Size[ getColumnSpan( mapping ) ];
    int soFar = 0;
    for ( Type propertyType : propertyTypes ) {
        final Size[] propertySizes = propertyType.dictatedSizes( mapping );
        System.arraycopy( propertySizes, 0, sizes, soFar, propertySizes.length );
        soFar += propertySizes.length;
    }
    return sizes;
}
项目:lams    文件:ComponentType.java   
@Override
public Size[] defaultSizes(Mapping mapping) throws MappingException {
    //Not called at runtime so doesn't matter if its slow :)
    final Size[] sizes = new Size[ getColumnSpan( mapping ) ];
    int soFar = 0;
    for ( Type propertyType : propertyTypes ) {
        final Size[] propertySizes = propertyType.defaultSizes( mapping );
        System.arraycopy( propertySizes, 0, sizes, soFar, propertySizes.length );
        soFar += propertySizes.length;
    }
    return sizes;
}
项目:lams    文件:ComponentType.java   
@Override
public boolean[] toColumnNullness(Object value, Mapping mapping) {
    boolean[] result = new boolean[ getColumnSpan( mapping ) ];
    if ( value == null ) {
        return result;
    }
    Object[] values = getPropertyValues( value, EntityMode.POJO ); //TODO!!!!!!!
    int loc = 0;
    for ( int i = 0; i < propertyTypes.length; i++ ) {
        boolean[] propertyNullness = propertyTypes[i].toColumnNullness( values[i], mapping );
        System.arraycopy( propertyNullness, 0, result, loc, propertyNullness.length );
        loc += propertyNullness.length;
    }
    return result;
}
项目:lams    文件:CompositeCustomType.java   
public int[] sqlTypes(Mapping mapping) throws MappingException {
    int[] result = new int[ getColumnSpan(mapping) ];
    int n=0;
    for ( Type type : userType.getPropertyTypes() ) {
        for ( int sqlType : type.sqlTypes( mapping ) ) {
            result[n++] = sqlType;
        }
    }
    return result;
}
项目:lams    文件:AnyType.java   
@Override
public Object fromXMLNode(Node xml, Mapping factory) throws HibernateException {
    throw new UnsupportedOperationException();
}
项目:hibernate-ogm-redis    文件:RedisHashType.java   
@Override
public int getColumnSpan(Mapping mapping) throws MappingException {
    return 1;
}
项目:hibernate-ogm-redis    文件:RedisJsonLongType.java   
@Override
public int getColumnSpan(Mapping mapping) throws MappingException {
    return 1;
}
项目:lams    文件:AnyType.java   
@Override
public int[] sqlTypes(Mapping mapping) throws MappingException {
    return ArrayHelper.join( discriminatorType.sqlTypes( mapping ), identifierType.sqlTypes( mapping ) );
}
项目:hibernate-ogm-redis    文件:RedisJsonByteType.java   
@Override
public int getColumnSpan(Mapping mapping) throws MappingException {
    return 1;
}
项目:lams    文件:CollectionType.java   
@Override
public Size[] defaultSizes(Mapping mapping) throws MappingException {
    return new Size[] { LEGACY_DEFAULT_SIZE };
}
项目:lams    文件:ToOne.java   
public boolean isValid(Mapping mapping) throws MappingException {
    if (referencedEntityName==null) {
        throw new MappingException("association must specify the referenced entity");
    }
    return super.isValid( mapping );
}
项目:lams    文件:MetaType.java   
public int[] sqlTypes(Mapping mapping) throws MappingException {
    return baseType.sqlTypes(mapping);
}
项目:lams    文件:Collection.java   
public boolean isValid(Mapping mapping) throws MappingException {
    return true;
}
项目:lams    文件:MetaType.java   
public boolean[] toColumnNullness(Object value, Mapping mapping) {
    throw new UnsupportedOperationException();
}
项目:lams    文件:SingleTableSubclass.java   
public void validate(Mapping mapping) throws MappingException {
    if(getDiscriminator()==null) {
        throw new MappingException("No discriminator found for " + getEntityName() + ". Discriminator is needed when 'single-table-per-hierarchy' is used and a class has subclasses");
    }
    super.validate(mapping);
}
项目:hibernate-ogm-ignite    文件:IgniteBigIntegerType.java   
@Override
public int getColumnSpan(Mapping mapping) throws MappingException {
    return 1;
}
项目:lams    文件:AbstractStandardBasicType.java   
public T fromXMLString(String xml, Mapping factory) throws HibernateException {
    return StringHelper.isEmpty( xml ) ? null : fromStringValue( xml );
}
项目:lams    文件:Property.java   
public boolean isValid(Mapping mapping) throws MappingException {
    return getValue().isValid(mapping);
}
项目:lams    文件:OneToMany.java   
public boolean isValid(Mapping mapping) throws MappingException {
    if (referencedEntityName==null) {
        throw new MappingException("one to many association must specify the referenced entity");
    }
    return true;
}