当前位置: 首页>>代码示例>>Java>>正文


Java IdentityGenerator类代码示例

本文整理汇总了Java中org.hibernate.id.IdentityGenerator的典型用法代码示例。如果您正苦于以下问题:Java IdentityGenerator类的具体用法?Java IdentityGenerator怎么用?Java IdentityGenerator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IdentityGenerator类属于org.hibernate.id包,在下文中一共展示了IdentityGenerator类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getGeneratorType

import org.hibernate.id.IdentityGenerator; //导入依赖的package包/类
private String getGeneratorType(AbstractEntityPersister entityPersister) {

        String generatorType = null;

        IdentifierGenerator generator = entityPersister != null ? entityPersister.getIdentifierGenerator() : null;
        if (generator != null) {
            if (generator instanceof IdentityGenerator)
                generatorType = "Identity";
            else if (generator instanceof Assigned)
                generatorType = "None";
            else
                generatorType = "KeyGenerator";
        }

        return generatorType;

    }
 
开发者ID:smysnk,项目名称:dockyard-controller,代码行数:18,代码来源:NewMetadataBuilder.java

示例2: getNativeIdentifierGeneratorClass

import org.hibernate.id.IdentityGenerator; //导入依赖的package包/类
/**
 * The class (which implements {@link org.hibernate.id.IdentifierGenerator})
 * which acts as this dialects native generation strategy.
 * <p/>
 * Comes into play whenever the user specifies the native generator.
 *
 * @return The native generator class.
 */
public Class getNativeIdentifierGeneratorClass() {
	if ( supportsIdentityColumns() ) {
		return IdentityGenerator.class;
	}
	else if ( supportsSequences() ) {
		return SequenceGenerator.class;
	}
	else {
		return TableHiLoGenerator.class;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:Dialect.java

示例3: isIdentityColumn

import org.hibernate.id.IdentityGenerator; //导入依赖的package包/类
public boolean isIdentityColumn(IdentifierGeneratorFactory identifierGeneratorFactory, Dialect dialect) {
	identifierGeneratorFactory.setDialect( dialect );
	return identifierGeneratorFactory.getIdentifierGeneratorClass( identifierGeneratorStrategy )
			.equals( IdentityGenerator.class );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:6,代码来源:SimpleValue.java

示例4: getNativeIdentifierGeneratorClass

import org.hibernate.id.IdentityGenerator; //导入依赖的package包/类
@Override
public Class getNativeIdentifierGeneratorClass() {
	return IdentityGenerator.class;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:Cache71Dialect.java

示例5: isIdentityColumn

import org.hibernate.id.IdentityGenerator; //导入依赖的package包/类
public boolean isIdentityColumn(Dialect dialect) {
	return IdentifierGeneratorFactory.getIdentifierGeneratorClass(identifierGeneratorStrategy, dialect)
			.equals(IdentityGenerator.class);
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:5,代码来源:SimpleValue.java

示例6: getNativeIdentifierGeneratorClass

import org.hibernate.id.IdentityGenerator; //导入依赖的package包/类
public Class getNativeIdentifierGeneratorClass() {
	return IdentityGenerator.class;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:4,代码来源:Cache71Dialect.java

示例7: addClass

import org.hibernate.id.IdentityGenerator; //导入依赖的package包/类
/**
 * Add the metadata for an entity.
 * 
 * @param meta
 */
void addClass(ClassMetadata meta) {
    Class type = meta.getMappedClass();

    String classKey = getEntityTypeName(type);
    HashMap<String, Object> cmap = new LinkedHashMap<String, Object>();
    _typeList.add(cmap);

    cmap.put("shortName", type.getSimpleName());
    cmap.put("namespace", type.getPackage().getName());

    EntityMetamodel metaModel = ((EntityPersister) meta).getEntityMetamodel();
    String superTypeName = metaModel.getSuperclass();
    if (superTypeName != null) {
        ClassMetadata superMeta = _sessionFactory.getClassMetadata(superTypeName);
        if (superMeta != null) {
            Class superClass = superMeta.getMappedClass();
            cmap.put("baseTypeName", getEntityTypeName(superClass));
        }
    }

    String genType = "None";
    if (meta instanceof EntityPersister) {
        EntityPersister entityPersister = (EntityPersister) meta;
        // multipart keys can never have an AutoGeneratedKeyType
        if (entityPersister.hasIdentifierProperty()) {
            IdentifierGenerator generator = entityPersister != null
                    ? entityPersister.getIdentifierGenerator()
                    : null;
            if (generator != null) {
                if (generator instanceof IdentityGenerator) {
                    genType = "Identity";
                } else if (generator instanceof Assigned || generator instanceof ForeignGenerator) {
                    genType = "None";
                } else {
                    genType = "KeyGenerator";
                }
                // TODO find the real generator
            }
        }
    }
    cmap.put("autoGeneratedKeyType", genType);

    String resourceName = pluralize(type.getSimpleName()); // TODO find the real name
    cmap.put("defaultResourceName", resourceName);
    _resourceMap.put(resourceName, classKey);

    ArrayList<HashMap<String, Object>> dataArrayList = new ArrayList<HashMap<String, Object>>();
    cmap.put("dataProperties", dataArrayList);
    ArrayList<HashMap<String, Object>> navArrayList = new ArrayList<HashMap<String, Object>>();
    cmap.put("navigationProperties", navArrayList);

    addClassProperties(meta, dataArrayList, navArrayList);
}
 
开发者ID:Breeze,项目名称:breeze.server.java,代码行数:59,代码来源:HibernateMetadata.java

示例8: addClass

import org.hibernate.id.IdentityGenerator; //导入依赖的package包/类
/**
 * Add the metadata for an entity.
 * @param meta
 */
void addClass(ClassMetadata meta) {

    Class type = meta.getMappedClass();

    String classKey = getEntityTypeName(type);
    HashMap<String, Object> cmap = new LinkedHashMap<String, Object>();
    typeList.add(cmap);

    cmap.put("shortName", type.getSimpleName());
    cmap.put("namespace", type.getPackage().getName());

    if (meta instanceof AbstractEntityPersister) {

        AbstractEntityPersister entityPersister = (AbstractEntityPersister) meta;
        String superClassEntityName = entityPersister.getMappedSuperclass();

        if (superClassEntityName != null) {
            Class superType = this.sessionFactory.getClassMetadata(superClassEntityName).getMappedClass();
            String baseTypeName = this.getEntityTypeName(superType);
            cmap.put("baseTypeName", baseTypeName);
        }

        IdentifierGenerator generator = entityPersister != null ? entityPersister.getIdentifierGenerator() : null;
        if (generator != null) {
            String genType = null;

            if (generator instanceof IdentityGenerator)
                genType = "Identity";
            else if (generator instanceof Assigned)
                genType = "None";
            else
                genType = "KeyGenerator";

            cmap.put("autoGeneratedKeyType", genType); // TODO find the real generator
        }
    }


    String resourceName = pluralize(type.getSimpleName()); // TODO find the real name
    cmap.put("defaultResourceName", resourceName);
    resourceMap.put(resourceName, classKey);

    ArrayList<HashMap<String, Object>> dataArrayList = new ArrayList<HashMap<String, Object>>();
    cmap.put("dataProperties", dataArrayList);

    ArrayList<HashMap<String, Object>> navArrayList = new ArrayList<HashMap<String, Object>>();
    cmap.put("navigationProperties", navArrayList);

    try {
        this.addClassProperties(meta, dataArrayList, navArrayList);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:smysnk,项目名称:dockyard-controller,代码行数:59,代码来源:MetadataBuilder.java

示例9: snapshotObject

import org.hibernate.id.IdentityGenerator; //导入依赖的package包/类
@Override
protected DatabaseObject snapshotObject(DatabaseObject example, DatabaseSnapshot snapshot) throws DatabaseException, InvalidExampleException {
    HibernateDatabase database = (HibernateDatabase) snapshot.getDatabase();
    Configuration cfg = database.getConfiguration();

    Dialect dialect = database.getDialect();
    Mapping mapping = cfg.buildMapping();

    org.hibernate.mapping.Table hibernateTable = findHibernateTable(example, snapshot);
    if (hibernateTable == null) {
        return null;
    }

    Table table = new Table().setName(hibernateTable.getName());
    PrimaryKey primaryKey = null;
    int pkColumnPosition = 0;
    LOG.info("Found table " + table.getName());

    table.setSchema(example.getSchema());

    Iterator columnIterator = hibernateTable.getColumnIterator();
    while (columnIterator.hasNext()) {
        org.hibernate.mapping.Column hibernateColumn = (org.hibernate.mapping.Column) columnIterator.next();
        Column column = new Column();
        column.setName(hibernateColumn.getName());

        String hibernateType = hibernateColumn.getSqlType(dialect, mapping);
        DataType dataType = toDataType(hibernateType, hibernateColumn.getSqlTypeCode());
        if (dataType == null) {
            throw new DatabaseException("Unable to find column data type for column " + hibernateColumn.getName());
        }

        column.setType(dataType);
        LOG.info("Found column " + column.getName() + " " + column.getType().toString());

        column.setRemarks(hibernateColumn.getComment());
        column.setDefaultValue(hibernateColumn.getDefaultValue());
        column.setNullable(hibernateColumn.isNullable());
        column.setCertainDataType(false);

        org.hibernate.mapping.PrimaryKey hibernatePrimaryKey = hibernateTable.getPrimaryKey();
        if (hibernatePrimaryKey != null) {
            boolean isPrimaryKeyColumn = false;
            //noinspection unchecked
            for (org.hibernate.mapping.Column pkColumn : (List<org.hibernate.mapping.Column>) hibernatePrimaryKey.getColumns()) {
                if (pkColumn.getName().equals(hibernateColumn.getName())) {
                    isPrimaryKeyColumn = true;
                    break;
                }
            }

            if (isPrimaryKeyColumn) {
                if (primaryKey == null) {
                    primaryKey = new PrimaryKey();
                    primaryKey.setName(hibernatePrimaryKey.getName());
                }
                primaryKey.addColumnName(pkColumnPosition++, column.getName());

                LiquibaseDataType liquibaseDataType = DataTypeFactory
			.getInstance().from(column.getType());
	// only columns types supporting auto increment -
	// DataTypeFactory
	if (isAutoIncrement(liquibaseDataType)) {

		if (dialect.getNativeIdentifierGeneratorClass().equals(
				IdentityGenerator.class)) {
			column.setAutoIncrementInformation(new Column.AutoIncrementInformation());
		}
	}
            }
        }
        column.setRelation(table);

        table.setPrimaryKey(primaryKey);
        table.getColumns().add(column);

    }

    return table;
}
 
开发者ID:exteso,项目名称:parkingfriends,代码行数:81,代码来源:JHipsterTableSnapshotGenerator.java

示例10: DefaultIdentifierGeneratorFactory

import org.hibernate.id.IdentityGenerator; //导入依赖的package包/类
/**
 * Constructs a new DefaultIdentifierGeneratorFactory.
 */
public DefaultIdentifierGeneratorFactory() {
	register( "uuid2", UUIDGenerator.class );
	register( "guid", GUIDGenerator.class );			// can be done with UUIDGenerator + strategy
	register( "uuid", UUIDHexGenerator.class );			// "deprecated" for new use
	register( "uuid.hex", UUIDHexGenerator.class ); 	// uuid.hex is deprecated
	register( "hilo", TableHiLoGenerator.class );
	register( "assigned", Assigned.class );
	register( "identity", IdentityGenerator.class );
	register( "select", SelectGenerator.class );
	register( "sequence", SequenceGenerator.class );
	register( "seqhilo", SequenceHiLoGenerator.class );
	register( "increment", IncrementGenerator.class );
	register( "foreign", ForeignGenerator.class );
	register( "sequence-identity", SequenceIdentityGenerator.class );
	register( "enhanced-sequence", SequenceStyleGenerator.class );
	register( "enhanced-table", TableGenerator.class );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:DefaultIdentifierGeneratorFactory.java


注:本文中的org.hibernate.id.IdentityGenerator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。