org.hibernate.boot.Metadata.getEntityBindings()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(12.1k)|赞(0)|评价(0)|浏览(148)

本文整理了Java中org.hibernate.boot.Metadata.getEntityBindings()方法的一些代码示例,展示了Metadata.getEntityBindings()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Metadata.getEntityBindings()方法的具体详情如下:
包路径:org.hibernate.boot.Metadata
类名称:Metadata
方法名:getEntityBindings

Metadata.getEntityBindings介绍

[英]Retrieves the PersistentClass entity metadata representation for known all entities. Returned collection is immutable
[中]检索已知所有实体的PersistentClass实体元数据表示形式。返回的集合是不可变的

代码示例

代码示例来源:origin: hibernate/hibernate-orm

@SuppressWarnings({"unchecked", "UnusedParameters"})
private static void applyRelationalConstraints(ValidatorFactory factory, ActivationContext activationContext) {
  final ConfigurationService cfgService = activationContext.getServiceRegistry().getService( ConfigurationService.class );
  if ( !cfgService.getSetting( BeanValidationIntegrator.APPLY_CONSTRAINTS, StandardConverters.BOOLEAN, true  ) ) {
    LOG.debug( "Skipping application of relational constraints from legacy Hibernate Validator" );
    return;
  }
  final Set<ValidationMode> modes = activationContext.getValidationModes();
  if ( ! ( modes.contains( ValidationMode.DDL ) || modes.contains( ValidationMode.AUTO ) ) ) {
    return;
  }
  applyRelationalConstraints(
      factory,
      activationContext.getMetadata().getEntityBindings(),
      cfgService.getSettings(),
      activationContext.getServiceRegistry().getService( JdbcServices.class ).getDialect(),
      new ClassLoaderAccessImpl(
          null,
          activationContext.getServiceRegistry().getService( ClassLoaderService.class )
      )
  );
}

代码示例来源:origin: hibernate/hibernate-orm

for ( PersistentClass entityBinding : metadata.getEntityBindings() ) {
  if ( entityBinding.isInherited() ) {
    continue;

代码示例来源:origin: hibernate/hibernate-orm

for ( PersistentClass persistentClass : metadata.getEntityBindings() ) {
  if ( persistentClass.getRootClass().isCached() ) {
    if ( ! names.add( persistentClass.getRootClass().getCacheRegionName() ) ) {

代码示例来源:origin: org.hibernate.orm/hibernate-core

/**
 * Retrieves the EntityMapping metadata representation for known all
 * entities. The returned collection is immutable.
 * <p/>
 * Note that {@link #getEntityHierarchies} is usually more appropriate
 *
 * @return All PersistentClass representations.
 */
default java.util.Collection<EntityMapping> getEntityMappings() {
  return getEntityBindings().stream().collect( Collectors.toList() );
}

代码示例来源:origin: hibernate/hibernate-search

public HibernateCoreIdUniquenessResolver(Metadata metadata) {
  Set<Class<?>> entities = new HashSet<>();
  for ( PersistentClass pc : metadata.getEntityBindings() ) {
    Class<?> mappedClass = pc.getMappedClass();
    if ( mappedClass != null ) {
      entities.add( mappedClass );
    }
  }
  this.entities = Collections.unmodifiableSet( entities );
}

代码示例来源:origin: hibernate/hibernate-search

@Override
public Iterator<Class<?>> getClassMappings() {
  return new ClassIterator( metadata.getEntityBindings().iterator() );
}

代码示例来源:origin: org.hibernate/hibernate-tools

public void visit(IssueCollector collector) {
  for (Iterator<PersistentClass> iter = getMetadata().getEntityBindings().iterator(); iter.hasNext();) {
    PersistentClass clazz = iter.next();
    this.visit(clazz, collector);				
  }
}

代码示例来源:origin: hibernate/hibernate-tools

public void visit(IssueCollector collector) {
  for (Iterator<PersistentClass> iter = getMetadata().getEntityBindings().iterator(); iter.hasNext();) {
    PersistentClass clazz = iter.next();
    this.visit(clazz, collector);				
  }
}

代码示例来源:origin: org.nuiton.topia/topia-persistence

@Override
public ImmutableSet<String> getSchemaNames() {
  ImmutableSet.Builder<String> result = ImmutableSet.builder();
  Collection<PersistentClass> classMappings = hibernateProvider.getMetaData().getEntityBindings();
  for (PersistentClass persistentClass : classMappings) {
    String schema = persistentClass.getIdentityTable().getSchema();
    if (StringUtils.isNotEmpty(schema)) {
      result.add(schema);
    }
  }
  return result.build();
}

代码示例来源:origin: org.hibernate/hibernate-tools

void process(GenericExporter ge) {
    Iterator<?> iterator = 
        ge.getCfg2JavaTool().getPOJOIterator(
            ge.getMetadata().getEntityBindings().iterator());
    Map<String, Object> additionalContext = new HashMap<String, Object>();
    while ( iterator.hasNext() ) {					
      POJOClass element = (POJOClass) iterator.next();
      ge.exportPersistentClass( additionalContext, element );                    
    }
  }
});

代码示例来源:origin: hibernate/hibernate-tools

void process(GenericExporter ge) {
    Iterator<?> iterator = 
        ge.getCfg2JavaTool().getPOJOIterator(
            ge.getMetadata().getEntityBindings().iterator());
    Map<String, Object> additionalContext = new HashMap<String, Object>();
    while ( iterator.hasNext() ) {					
      POJOClass element = (POJOClass) iterator.next();
      ge.exportPersistentClass( additionalContext, element );                    
    }
  }
});

代码示例来源:origin: hibernate/hibernate-tools

@Test
  public void testPackageNames() {
    Iterator<PersistentClass> iter = metadataDescriptor
        .createMetadata()
        .getEntityBindings()
        .iterator();
    while (iter.hasNext() ) {
      PersistentClass element = iter.next();
      Assert.assertEquals("org.reveng", StringHelper.qualifier(element.getClassName() ) );
    }
  }
}

代码示例来源:origin: com.blazebit/blaze-persistence-integration-hibernate-5

@Override
public void integrate(Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
  for (PersistentClass clazz : metadata.getEntityBindings()) {
    Class<?> entityClass = clazz.getMappedClass();
    
    if (entityClass != null && entityClass.isAnnotationPresent(CTE.class)) {
      clazz.getTable().setSubselect("select * from " + clazz.getJpaEntityName());
    }
  }
  serviceRegistry.locateServiceBinding(PersisterClassResolver.class).setService(new CustomPersisterClassResolver());
  TableNameFormatter formatter = new NativeTableNameFormatter(sessionFactory.getJdbcServices().getJdbcEnvironment().getQualifiedObjectNameFormatter());
  serviceRegistry.locateServiceBinding(Database.class).setService(new SimpleDatabase(getTableIterator(metadata.getDatabase().getNamespaces()), sessionFactory.getDialect(), formatter, metadata));
}

代码示例来源:origin: Blazebit/blaze-persistence

@Override
public void integrate(Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
  for (PersistentClass clazz : metadata.getEntityBindings()) {
    Class<?> entityClass = clazz.getMappedClass();
    
    if (entityClass != null && entityClass.isAnnotationPresent(CTE.class)) {
      clazz.getTable().setSubselect("select * from " + clazz.getJpaEntityName());
    }
  }
  serviceRegistry.locateServiceBinding(PersisterClassResolver.class).setService(new CustomPersisterClassResolver());
  TableNameFormatter formatter = new NativeTableNameFormatter(sessionFactory.getJdbcServices().getJdbcEnvironment().getQualifiedObjectNameFormatter());
  serviceRegistry.locateServiceBinding(Database.class).setService(new SimpleDatabase(getTableIterator(metadata.getDatabase().getNamespaces()), sessionFactory.getDialect(), formatter, metadata));
}

代码示例来源:origin: Blazebit/blaze-persistence

@Override
public void integrate(Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
  // TODO: remember metadata for exact column types
  for (PersistentClass clazz : metadata.getEntityBindings()) {
    Class<?> entityClass = clazz.getMappedClass();
    
    if (entityClass != null && entityClass.isAnnotationPresent(CTE.class)) {
      clazz.getTable().setSubselect("select * from " + clazz.getJpaEntityName());
    }
  }
  serviceRegistry.locateServiceBinding(PersisterClassResolver.class).setService(new CustomPersisterClassResolver());
  TableNameFormatter formatter = new NativeTableNameFormatter(sessionFactory.getJdbcServices().getJdbcEnvironment().getQualifiedObjectNameFormatter());
  serviceRegistry.locateServiceBinding(Database.class).setService(new SimpleDatabase(getTableIterator(metadata.getDatabase().getNamespaces()), sessionFactory.getDialect(), formatter, metadata));
}

代码示例来源:origin: com.blazebit/blaze-persistence-integration-hibernate-6.0

@Override
public void integrate(Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
  for (PersistentClass clazz : metadata.getEntityBindings()) {
    Class<?> entityClass = clazz.getMappedClass();
    
    if (entityClass != null && entityClass.isAnnotationPresent(CTE.class)) {
      clazz.getTable().setSubselect("select * from " + clazz.getJpaEntityName());
    }
  }
  serviceRegistry.locateServiceBinding(PersisterClassResolver.class).setService(new CustomPersisterClassResolver());
  TableNameFormatter formatter = new NativeTableNameFormatter(sessionFactory.getJdbcServices().getJdbcEnvironment().getQualifiedObjectNameFormatter());
  serviceRegistry.locateServiceBinding(Database.class).setService(new SimpleDatabase(getTableIterator(metadata.getDatabase().getNamespaces()), sessionFactory.getJdbcServices().getDialect(), formatter, metadata));
}

代码示例来源:origin: Blazebit/blaze-persistence

@Override
public void integrate(Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
  // TODO: remember metadata for exact column types
  for (PersistentClass clazz : metadata.getEntityBindings()) {
    Class<?> entityClass = clazz.getMappedClass();
    
    if (entityClass != null && entityClass.isAnnotationPresent(CTE.class)) {
      clazz.getTable().setSubselect("select * from " + clazz.getJpaEntityName());
    }
  }
  serviceRegistry.locateServiceBinding(PersisterClassResolver.class).setService(new CustomPersisterClassResolver());
  TableNameFormatter formatter = new NativeTableNameFormatter(sessionFactory.getJdbcServices().getJdbcEnvironment().getQualifiedObjectNameFormatter());
  serviceRegistry.locateServiceBinding(Database.class).setService(new SimpleDatabase(getTableIterator(metadata.getDatabase().getNamespaces()), sessionFactory.getDialect(), formatter, metadata));
}

代码示例来源:origin: Blazebit/blaze-persistence

@Override
public void integrate(Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
  // TODO: remember metadata for exact column types
  for (PersistentClass clazz : metadata.getEntityBindings()) {
    Class<?> entityClass = clazz.getMappedClass();
    
    if (entityClass != null && entityClass.isAnnotationPresent(CTE.class)) {
      clazz.getTable().setSubselect("select * from " + clazz.getJpaEntityName());
    }
  }
  serviceRegistry.locateServiceBinding(PersisterClassResolver.class).setService(new CustomPersisterClassResolver());
  TableNameFormatter formatter = new NativeTableNameFormatter(sessionFactory.getJdbcServices().getJdbcEnvironment().getQualifiedObjectNameFormatter());
  serviceRegistry.locateServiceBinding(Database.class).setService(new SimpleDatabase(getTableIterator(metadata.getDatabase().getNamespaces()), sessionFactory.getDialect(), formatter, metadata));
}

代码示例来源:origin: com.blazebit/blaze-persistence-integration-hibernate-5.2

@Override
public void integrate(Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
  // TODO: remember metadata for exact column types
  for (PersistentClass clazz : metadata.getEntityBindings()) {
    Class<?> entityClass = clazz.getMappedClass();
    
    if (entityClass != null && entityClass.isAnnotationPresent(CTE.class)) {
      clazz.getTable().setSubselect("select * from " + clazz.getJpaEntityName());
    }
  }
  serviceRegistry.locateServiceBinding(PersisterClassResolver.class).setService(new CustomPersisterClassResolver());
  TableNameFormatter formatter = new NativeTableNameFormatter(sessionFactory.getJdbcServices().getJdbcEnvironment().getQualifiedObjectNameFormatter());
  serviceRegistry.locateServiceBinding(Database.class).setService(new SimpleDatabase(getTableIterator(metadata.getDatabase().getNamespaces()), sessionFactory.getDialect(), formatter, metadata));
}

代码示例来源:origin: Blazebit/blaze-persistence

@Override
public void integrate(Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
  for (PersistentClass clazz : metadata.getEntityBindings()) {
    Class<?> entityClass = clazz.getMappedClass();
    
    if (entityClass != null && entityClass.isAnnotationPresent(CTE.class)) {
      clazz.getTable().setSubselect("select * from " + clazz.getJpaEntityName());
    }
  }
  serviceRegistry.locateServiceBinding(PersisterClassResolver.class).setService(new CustomPersisterClassResolver());
  TableNameFormatter formatter = new NativeTableNameFormatter(sessionFactory.getJdbcServices().getJdbcEnvironment().getQualifiedObjectNameFormatter());
  serviceRegistry.locateServiceBinding(Database.class).setService(new SimpleDatabase(getTableIterator(metadata.getDatabase().getNamespaces()), sessionFactory.getJdbcServices().getDialect(), formatter, metadata));
}

相关文章