本文整理汇总了Java中org.hibernate.engine.spi.Mapping类的典型用法代码示例。如果您正苦于以下问题:Java Mapping类的具体用法?Java Mapping怎么用?Java Mapping使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Mapping类属于org.hibernate.engine.spi包,在下文中一共展示了Mapping类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validate
import org.hibernate.engine.spi.Mapping; //导入依赖的package包/类
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();
}
示例2: UnionSubclassEntityPersister
import org.hibernate.engine.spi.Mapping; //导入依赖的package包/类
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;
}
示例3: getAliasedLHSColumnNames
import org.hibernate.engine.spi.Mapping; //导入依赖的package包/类
/**
* 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 );
}
}
}
示例4: createEntityPersister
import org.hibernate.engine.spi.Mapping; //导入依赖的package包/类
@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 );
}
示例5: validate
import org.hibernate.engine.spi.Mapping; //导入依赖的package包/类
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()
);
}
}
示例6: validate
import org.hibernate.engine.spi.Mapping; //导入依赖的package包/类
@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();
}
示例7: sqlCreateString
import org.hibernate.engine.spi.Mapping; //导入依赖的package包/类
public String sqlCreateString(Dialect dialect, Mapping mapping, String defaultCatalog, String defaultSchema)
throws HibernateException {
return buildSqlCreateIndexString(
dialect,
getName(),
getTable(),
getColumnIterator(),
columnOrderMap,
false,
defaultCatalog,
defaultSchema
);
}
示例8: validateColumns
import org.hibernate.engine.spi.Mapping; //导入依赖的package包/类
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 )
);
}
}
}
}
示例9: prepareTemporaryTables
import org.hibernate.engine.spi.Mapping; //导入依赖的package包/类
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 );
}
}
示例10: sqlCreateString
import org.hibernate.engine.spi.Mapping; //导入依赖的package包/类
@Override
public String sqlCreateString(Dialect dialect, Mapping p,
String defaultCatalog, String defaultSchema) {
return dialect.getUniqueDelegate().getAlterTableToAddUniqueKeyCommand(
this, defaultCatalog, defaultSchema
);
}
示例11: getColumnSpan
import org.hibernate.engine.spi.Mapping; //导入依赖的package包/类
public int getColumnSpan(Mapping mapping) throws MappingException {
Type[] types = userType.getPropertyTypes();
int n=0;
for ( Type type : types ) {
n += type.getColumnSpan( mapping );
}
return n;
}
示例12: initIdentifierPropertyPaths
import org.hibernate.engine.spi.Mapping; //导入依赖的package包/类
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 );
}
}
示例13: initDiscriminatorPropertyPath
import org.hibernate.engine.spi.Mapping; //导入依赖的package包/类
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() );
}
示例14: getIdentifierOrUniqueKeyPropertyName
import org.hibernate.engine.spi.Mapping; //导入依赖的package包/类
/**
* 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;
}
}
示例15: CompositeElementPropertyMapping
import org.hibernate.engine.spi.Mapping; //导入依赖的package包/类
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);
}