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


Java MetadataImplementor类代码示例

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


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

示例1: generateDDL

import org.hibernate.boot.spi.MetadataImplementor; //导入依赖的package包/类
private void generateDDL() throws Exception {
    final MetadataImplementor md = createMetaData();
    final SchemaExport export = new SchemaExport(md);

    // drop
    {
        export.setDelimiter(";");
        export.setOutputFile(getRefPath() + "/db-drop.sql");
        export.setFormat(true);
        export.execute(true, false, true, false);
    }
    // create
    {
        export.setDelimiter(";");
        export.setOutputFile(getRefPath() + "/db-create.sql");
        export.setFormat(true);
        export.execute(true, false, false, true);
    }
}
 
开发者ID:shared-vd,项目名称:tipi-engine,代码行数:20,代码来源:TipiDDLGeneratorTest.java

示例2: addTableName

import org.hibernate.boot.spi.MetadataImplementor; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void addTableName(MetadataImplementor metadata, ArrayList<String> tables, Table table, String aSchemaName) {
    String name = (null == aSchemaName) ? "" : aSchemaName + ".";
    name += table.getName();
    if (tables.contains(name)) {
        return;
    }

    final Collection<Table> ts = metadata.collectTableMappings();
    for (Table t : ts) {
        if (t.equals(table)) {
            continue;
        }
        Iterator<ForeignKey> relationships = t.getForeignKeyIterator();
        while (relationships.hasNext()) {
            ForeignKey fk = relationships.next();
            if (fk.getReferencedTable().equals(table)) {
                addTableName(metadata, tables, fk.getTable(), aSchemaName);
            }
        }
    }
    tables.add(name);
}
 
开发者ID:shared-vd,项目名称:tipi-engine,代码行数:24,代码来源:HibernateMetaDataTruncater.java

示例3: outputDdl

import org.hibernate.boot.spi.MetadataImplementor; //导入依赖的package包/类
private void outputDdl(String packageName, String dialect, String fileName) {
    LocalSessionFactoryBean sfBean = sfBean(packageName, dialect);
    StandardServiceRegistry serviceRegistry = sfBean.getConfiguration().getStandardServiceRegistryBuilder().build();
    try {
        String outputFile = OutputRoot + fileName;
        Files.deleteIfExists(Paths.get(outputFile));
        MetadataImplementor metadata = metadata(sfBean, serviceRegistry);
        
        SchemaExport export = new SchemaExport();
        export.setDelimiter(";");
        export.setFormat(FormatSql);
        export.setOutputFile(outputFile);
        export.create(EnumSet.of(TargetType.SCRIPT), metadata);
    } catch (Exception e) {
        throw new InvocationException(e);
    } finally {
        StandardServiceRegistryBuilder.destroy( serviceRegistry );
    }
}
 
开发者ID:jkazama,项目名称:sample-boot-micro,代码行数:20,代码来源:DdlExporter.java

示例4: buildDomainMetamodel

import org.hibernate.boot.spi.MetadataImplementor; //导入依赖的package包/类
public static SqmDomainMetamodel buildDomainMetamodel(Class... managedClasses) {
	final MetadataSources metadataSources = new MetadataSources();
	for ( Class managedClass : managedClasses ) {
		metadataSources.addAnnotatedClass( managedClass );
	}

	final MetadataImplementor metadata = (MetadataImplementor) metadataSources.buildMetadata();
	metadata.validate();

	// at this point we have access to the mapping Metadata (PersistentClass, etc)
	//		use it to build the testing DomainMetamodel/TypeConfiguration

	final ExplicitSqmDomainMetamodel domainMetamodel = new ExplicitSqmDomainMetamodel( metadata );

	populateDatabaseModel( metadata, domainMetamodel );
	populateMappingModel( metadata, domainMetamodel );

	return domainMetamodel;
}
 
开发者ID:hibernate,项目名称:hibernate-semantic-query,代码行数:20,代码来源:OrmHelper.java

示例5: populateMappingModel

import org.hibernate.boot.spi.MetadataImplementor; //导入依赖的package包/类
private static void populateMappingModel(MetadataImplementor mappingMetadata, ExplicitSqmDomainMetamodel domainMetamodel) {
//		final PersisterFactory persisterFactory = getSessionFactory().getServiceRegistry().getService( PersisterFactory.class );
		final PersisterFactory persisterFactory = domainMetamodel.getPersisterFactory();

		for ( final PersistentClass model : mappingMetadata.getEntityBindings() ) {
//			final EntityRegionAccessStrategy accessStrategy = getSessionFactory().getCache().determineEntityRegionAccessStrategy(
//					model
//			);
			final EntityRegionAccessStrategy accessStrategy = null;

//			final NaturalIdRegionAccessStrategy naturalIdAccessStrategy = getSessionFactory().getCache().determineNaturalIdRegionAccessStrategy(
//					model
//			);
			final NaturalIdRegionAccessStrategy naturalIdAccessStrategy = null;

			persisterFactory.createEntityPersister(
					model,
					accessStrategy,
					naturalIdAccessStrategy,
					domainMetamodel
			);
		}

		persisterFactory.finishUp( domainMetamodel );
	}
 
开发者ID:hibernate,项目名称:hibernate-semantic-query,代码行数:26,代码来源:OrmHelper.java

示例6: export

import org.hibernate.boot.spi.MetadataImplementor; //导入依赖的package包/类
protected void export(Class<? extends Dialect> dialect, String app_key, MetadataSources metadata, boolean create, boolean drop) {
    Assert.notNull(dialect, "dialect is invalid [null]");
    Assert.notNull(app_key, "app_key is invalid [null]");
    Assert.notNull(metadata, "metadata is invalid [null]");

    SchemaExport schemaExport = new SchemaExport((MetadataImplementor) metadata.buildMetadata());
    schemaExport.setDelimiter(";");
    schemaExport.setFormat(true);

    if (create) {
        // Generate create script
        schemaExport.setOutputFile(String.format("target/%s_ddl_%s_create.sql", app_key, dialect.getSimpleName()));
        schemaExport.execute(true, false, false, true);
    }

    if (drop) {
        // Generate drop script
        schemaExport.setOutputFile(String.format("target/%s_ddl_%s_drop.sql", app_key, dialect.getSimpleName()));
        schemaExport.execute(true, false, true, false);
    }
}
 
开发者ID:bartgerard,项目名称:ubrew_v0.1,代码行数:22,代码来源:SchemaExporter.java

示例7: createMetadataImplementor

import org.hibernate.boot.spi.MetadataImplementor; //导入依赖的package包/类
public static MetadataImplementor createMetadataImplementor(String dialect, String[] hibernatePackagesToScan) {
    final MetadataSources metadata = new MetadataSources(
            new StandardServiceRegistryBuilder()
                    .applySetting("hibernate.dialect", dialect)
                    .build());

    for (String packageName : hibernatePackagesToScan) {
        for (Class clazz : HibernateMetaDataHelper.getClasses(packageName)) {
            metadata.addAnnotatedClass(clazz);
        }
    }
    return (MetadataImplementor) metadata.buildMetadata();
}
 
开发者ID:shared-vd,项目名称:tipi-engine,代码行数:14,代码来源:HibernateMetaDataHelper.java

示例8: afterContextInitialization

import org.hibernate.boot.spi.MetadataImplementor; //导入依赖的package包/类
protected void afterContextInitialization() {
    this.dataSource = applicationContext.getBean(DataSource.class);
    final Environment env = applicationContext.getBean(Environment.class);
    final String dialect = env.getRequiredProperty("spring.jpa.database-platform");
    final String[] hibernatePackagesToScan = new String[]{DbActivity.class.getPackage().getName()};
    final MetadataImplementor metadataImplementor = HibernateMetaDataHelper.createMetadataImplementor(dialect, hibernatePackagesToScan);
    truncater = new HibernateMetaDataTruncater(dataSource, metadataImplementor);
}
 
开发者ID:shared-vd,项目名称:tipi-engine,代码行数:9,代码来源:AbstractSpringBootTruncaterTest.java

示例9: testDbSchema

import org.hibernate.boot.spi.MetadataImplementor; //导入依赖的package包/类
@Test
public void testDbSchema() {
    MetadataSources metadata = new MetadataSources(new StandardServiceRegistryBuilder()
                    .applySetting("hibernate.dialect", "org.hibernate.dialect.H2Dialect").build());

    metadata.addAnnotatedClass(ConsoleEntity.class);
    metadata.addAnnotatedClass(GameEntity.class);
    metadata.addAnnotatedClass(UserEntity.class);
    metadata.addAnnotatedClass(RoleEntity.class);
    metadata.addAnnotatedClass(LibraryEntity.class);
    metadata.addAnnotatedClass(BorrowEntity.class);

    SchemaExport export = new SchemaExport((MetadataImplementor) metadata.buildMetadata());
    export.create(Target.SCRIPT);
}
 
开发者ID:MannanM,项目名称:corporate-game-share,代码行数:16,代码来源:SchemaTranslator.java

示例10: prepare

import org.hibernate.boot.spi.MetadataImplementor; //导入依赖的package包/类
@Override
public void prepare(JdbcServices jdbcServices, JdbcConnectionAccess connectionAccess, MetadataImplementor metadata, SessionFactoryOptions sessionFactoryOptions) {
    ConfigurationService configService = sessionFactoryOptions.getServiceRegistry().getService(ConfigurationService.class);
    this.fullyQualifiedTableName = Objects.requireNonNull(configService.getSetting(TABLE, String.class, null), "Property " + TABLE + " must be set.");
    this.idColumn = configService.getSetting(ID_COLUMN, String.class, "ID");
    this.discriminatorColumn = configService.getSetting(DISCRIMINATOR_COLUMN, String.class, "ENTITY_NAME");
    this.cleanRows = configService.getSetting(CLEAN_ROWS, StandardConverters.BOOLEAN, false);
}
 
开发者ID:grimsa,项目名称:hibernate-single-table-bulk-id-strategy,代码行数:9,代码来源:SingleGlobalTemporaryTableBulkIdStrategy.java

示例11: testSchemaExport

import org.hibernate.boot.spi.MetadataImplementor; //导入依赖的package包/类
@Test
public void testSchemaExport() {
	ServiceRegistry serviceRegistry =
		new StandardServiceRegistryBuilder().configure().build();

	MetadataImplementor metadataImplementor =
		(MetadataImplementor) new MetadataSources(serviceRegistry).buildMetadata();

	SchemaExport schemaExport = new SchemaExport(serviceRegistry, metadataImplementor);
	schemaExport.create(true, true);
}
 
开发者ID:bejondshao,项目名称:personal,代码行数:12,代码来源:ORMappingTest.java

示例12: populateDatabaseModel

import org.hibernate.boot.spi.MetadataImplementor; //导入依赖的package包/类
private static void populateDatabaseModel(MetadataImplementor metadata, ExplicitSqmDomainMetamodel domainMetamodel) {
		final Database database = metadata.getDatabase();
		final DatabaseModelImpl databaseModel = (DatabaseModelImpl) domainMetamodel.getDatabaseModel();

		// todo : apply PhysicalNamingStrategy here, rather than as we create the "mapping model"?

		// todo : we need DatabaseModel to incorporate catalogs/schemas in some fashion
		//		either like org.hibernate.boot.model.relational.Database does
		//		or via catalogs/schemas-specific names
		for ( Namespace namespace : database.getNamespaces() ) {
			for ( Table mappingTable : namespace.getTables() ) {
				// todo : incorporate mapping Table's isAbstract indicator
				final org.hibernate.orm.persister.common.spi.Table table;
				if ( mappingTable instanceof DenormalizedTable ) {
					// this is akin to a UnionSubclassTable
					throw new NotYetImplementedException( "DenormalizedTable support not yet implemented" );
				}
				else if ( mappingTable.getSubselect() != null ) {
					table = new DerivedTable( mappingTable.getSubselect() );
				}
				else {
//					final JdbcEnvironment jdbcEnvironment = sessionFactory.getJdbcServices().getJdbcEnvironment();
//					final String qualifiedTableName = jdbcEnvironment.getQualifiedObjectNameFormatter().format(
//							mappingTable.getQualifiedTableName(),
//							jdbcEnvironment.getDialect()
//					);
					final String qualifiedTableName = mappingTable.getQualifiedTableName().render();
					table = new PhysicalTable( qualifiedTableName );
				}

				databaseModel.registerTable( table );
			}
		}
	}
 
开发者ID:hibernate,项目名称:hibernate-semantic-query,代码行数:35,代码来源:OrmHelper.java

示例13: get

import org.hibernate.boot.spi.MetadataImplementor; //导入依赖的package包/类
@Override
public DataStore get() {
    // method to force class initialization
    MetadataSources metadataSources = new MetadataSources(
            new StandardServiceRegistryBuilder()
                    .configure("hibernate.cfg.xml")
                    .applySetting(Environment.CURRENT_SESSION_CONTEXT_CLASS, "thread")
                    .applySetting(Environment.URL, "jdbc:mysql://localhost:"
                            + System.getProperty("mysql.port", "3306")
                            + "/root?serverTimezone=UTC")
                    .applySetting(Environment.USER, "root")
                    .applySetting(Environment.PASS, "root")
                    .build());

    metadataSources.addAnnotatedClass(HibernateUser.class);

    MetadataImplementor metadataImplementor = (MetadataImplementor) metadataSources.buildMetadata();

    // create example tables from beans
    SchemaExport schemaExport = new SchemaExport(metadataImplementor); //.setHaltOnError(true);
    schemaExport.drop(false, true);
    schemaExport.execute(false, true, false, true);

    if (!schemaExport.getExceptions().isEmpty()) {
        throw new RuntimeException(schemaExport.getExceptions().toString());
    }

    LATEST_HIBERNATE_STORE = new AbstractHibernateStore.Builder(metadataImplementor.buildSessionFactory())
        .withScrollEnabled(true)
        .withScrollMode(ScrollMode.FORWARD_ONLY)
        .build();

    BridgeableRedisStore hbaseStore = new BridgeableRedisStore();

    return new MultiplexManager(LATEST_HIBERNATE_STORE, hbaseStore);
}
 
开发者ID:yahoo,项目名称:elide,代码行数:37,代码来源:BridgeableStoreSupplier.java

示例14: prepare

import org.hibernate.boot.spi.MetadataImplementor; //导入依赖的package包/类
@Override
public void prepare(
		JdbcServices jdbcServices,
		JdbcConnectionAccess jdbcConnectionAccess,
		MetadataImplementor metadataImplementor,
		SessionFactoryOptions sessionFactoryOptions) {

}
 
开发者ID:epiresdasilva,项目名称:cte-multi-table-bulk-id-stategy,代码行数:9,代码来源:CTEMultiTableBulkIdStrategy.java

示例15: createMetaData

import org.hibernate.boot.spi.MetadataImplementor; //导入依赖的package包/类
private MetadataImplementor createMetaData() throws Exception {
    return HibernateMetaDataHelper.createMetadataImplementor(getDialect(), getHibernatePackagesToScan());
}
 
开发者ID:shared-vd,项目名称:tipi-engine,代码行数:4,代码来源:TipiDDLGeneratorTest.java


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