本文整理汇总了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;
}
示例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;
}
}
示例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 );
}
示例4: getNativeIdentifierGeneratorClass
import org.hibernate.id.IdentityGenerator; //导入依赖的package包/类
@Override
public Class getNativeIdentifierGeneratorClass() {
return IdentityGenerator.class;
}
示例5: isIdentityColumn
import org.hibernate.id.IdentityGenerator; //导入依赖的package包/类
public boolean isIdentityColumn(Dialect dialect) {
return IdentifierGeneratorFactory.getIdentifierGeneratorClass(identifierGeneratorStrategy, dialect)
.equals(IdentityGenerator.class);
}
示例6: getNativeIdentifierGeneratorClass
import org.hibernate.id.IdentityGenerator; //导入依赖的package包/类
public Class getNativeIdentifierGeneratorClass() {
return IdentityGenerator.class;
}
示例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);
}
示例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();
}
}
示例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;
}
示例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 );
}