@Override public ServiceRegistry getServiceRegistry() { return metadata.getMetadataBuildingOptions().getServiceRegistry(); }
@Override public Collection<Table> collectTableMappings() { return delegate.collectTableMappings(); }
@Override public Collection<PersistentClass> getEntityBindings() { return delegate.getEntityBindings(); }
@Override public void prepare(MetadataImplementor metadata) { if ( callbackBuilder == null ) { // TODO : not needed anymore when the deprecate constructor will be removed this.callbackBuilder = CallbacksFactory.buildCallbackBuilder( sessionFactory, metadata.getMetadataBuildingOptions().getReflectionManager() ); } for ( PersistentClass persistentClass : metadata.getEntityBindings() ) { if ( persistentClass.getClassName() == null ) { // we can have non java class persisted by hibernate continue; } callbackBuilder.buildCallbacksForEntity( persistentClass.getClassName(), callbackRegistry ); for ( Iterator propertyIterator = persistentClass.getDeclaredPropertyIterator(); propertyIterator.hasNext(); ) { Property property = (Property) propertyIterator.next(); if ( property.getType().isComponentType() ) { callbackBuilder.buildCallbacksForEmbeddable( property, persistentClass.getClassName(), callbackRegistry ); } } } }
@Test public void testMapping() { PersistentClass pc = metadata().getEntityBinding( UnversionedOptimisticLockingFieldEntity.class.getName() + "_AUD" ); Iterator pi = pc.getPropertyIterator(); while ( pi.hasNext() ) { Property p = (Property) pi.next(); assert !"optLocking".equals( p.getName() ); } } }
this.imports.putAll( mappingMetadata.getImports() ); for ( final PersistentClass model : mappingMetadata.getEntityBindings() ) { final NavigableRole rootEntityRole = new NavigableRole( model.getRootClass().getEntityName() ); final EntityDataAccess accessStrategy = sessionFactory.getCache().getEntityRegionAccess( rootEntityRole ); for ( final Collection model : mappingMetadata.getCollectionBindings() ) { final NavigableRole navigableRole = new NavigableRole( model.getRole() ); MetadataContext context = new MetadataContext( sessionFactory, mappingMetadata.getMappedSuperclassMappingsCopy(), jpaMetaModelPopulationSetting ); for ( PersistentClass entityBinding : mappingMetadata.getEntityBindings() ) { locateOrBuildEntityType( entityBinding, context ); this.jpaEntityTypesByEntityName.putAll( context.getEntityTypesByEntityName() ); applyNamedEntityGraphs( mappingMetadata.getNamedEntityGraphs().values() );
this.typeHelper = new TypeLocatorImpl( metadata.getTypeConfiguration().getTypeResolver() ); this.filters.putAll( metadata.getFilterDefinitions() ); metadata.getEntityBindings().stream().filter( model -> !model.isInherited() ).forEach( model -> { IdentifierGenerator generator = model.getIdentifier().createIdentifierGenerator( metadata.getIdentifierGeneratorFactory(), jdbcServices.getJdbcEnvironment().getDialect(), settings.getDefaultCatalogName(), this.metamodel = metadata.getTypeConfiguration().scope( this ); ( (MetamodelImpl) this.metamodel ).initialize( metadata, this.namedQueryRepository = metadata.buildNamedQueryRepository( this ); for ( org.hibernate.mapping.FetchProfile mappingProfile : metadata.getFetchProfiles() ) { final FetchProfile fetchProfile = new FetchProfile( mappingProfile.getName() ); for ( org.hibernate.mapping.FetchProfile.Fetch mappingFetch : mappingProfile.getFetches() ) {
@Override public Database getDatabase() { return delegate.getDatabase(); }
@Override public SessionFactoryBuilder getSessionFactoryBuilder() { return delegate.getSessionFactoryBuilder(); }
assertEquals( AccessType.READ_ONLY, metadata.getMetadataBuildingOptions().getMappingDefaults().getImplicitCacheAccessType() ); final SessionFactoryImplementor sf = (SessionFactoryImplementor) metadata.buildSessionFactory(); try { final EntityPersister persister = sf.getMetamodel().entityPersister( TheEntity.class.getName() );
for ( PersistentClass bootEntityDescriptor : mappingMetadata.getEntityBindings() ) { final AccessType accessType = AccessType.fromExternalName( bootEntityDescriptor.getCacheConcurrencyStrategy() ); for ( Collection collection : mappingMetadata.getCollectionBindings() ) { final AccessType accessType = AccessType.fromExternalName( collection.getCacheConcurrencyStrategy() ); if ( accessType != null ) {
@Test @TestForIssue( jiraKey = "HHH-9936" ) public void testMultipleUsesOfDefaultSequenceName() { final MetadataImplementor metadata = (MetadataImplementor) new MetadataSources( ssr ) .addAnnotatedClass( Entity1.class ) .addAnnotatedClass( Entity2.class ) .buildMetadata(); metadata.validate(); assertEquals( 0, metadata.getDatabase().getAuxiliaryDatabaseObjects().size() ); int count = 0; for ( Namespace namespace : metadata.getDatabase().getNamespaces() ) { for ( Sequence sequence : namespace.getSequences() ) { count++; } } assertEquals( 1, count ); }
@Override public org.hibernate.mapping.Collection getCollectionBinding(String role) { return delegate.getCollectionBinding( role ); }
MetadataImplementor metadata = (MetadataImplementor) database.getMetadata(); Collection<PersistentClass> entityBindings = metadata.getEntityBindings(); Iterator<PersistentClass> tableMappings = entityBindings.iterator(); if (!persistentClass.isInherited()) { IdentifierGenerator ig = persistentClass.getIdentifier().createIdentifierGenerator( metadata.getIdentifierGeneratorFactory(), database.getDialect(), null, Collection<org.hibernate.mapping.Collection> collectionBindings = metadata.getCollectionBindings(); Iterator<org.hibernate.mapping.Collection> collIter = collectionBindings.iterator(); while (collIter.hasNext()) {
metadata.validate(); for ( Table table : metadata.collectTableMappings() ) { for ( Map.Entry<ForeignKeyKey, ForeignKey> entry : table.getForeignKeys().entrySet() ) { assertFalse(
PersistentClass tester = metadata.getEntityBinding( EntityWithConvertibleField.class.getName() ); Property nameProp = tester.getProperty( "convertibleEnum" ); SimpleValue nameValue = (SimpleValue) nameProp.getValue(); final SessionFactory sf = metadata.buildSessionFactory(); try { Session s = sf.openSession();
String ownerForeignKeyNameExpected, String inverseForeignKeyNameExpected) { final org.hibernate.mapping.Collection collection = metadata().getCollectionBinding( ownerEntityClass.getName() + '.' + ownerCollectionPropertyName ); final org.hibernate.mapping.Table table = collection.getCollectionTable(); assertEquals( expectedCollectionTableName, table.getName() ); final org.hibernate.mapping.Collection ownerCollection = metadata().getCollectionBinding( ownerEntityClass.getName() + '.' + ownerCollectionPropertyName ); metadata().getEntityBinding( associatedEntityType.getAssociatedEntityName() ); assertEquals( 1, associatedPersistentClass.getKey().getColumnSpan() ); if ( inverseCollectionPropertyName != null ) { final org.hibernate.mapping.Collection inverseCollection = metadata().getCollectionBinding( associatedPersistentClass.getEntityName() + '.' + inverseCollectionPropertyName );
HibernateDatabase database = (HibernateDatabase) snapshot.getDatabase(); MetadataImplementor metadata = (MetadataImplementor) database.getMetadata(); Iterator<PersistentClass> classMappings = metadata.getEntityBindings().iterator(); if (!persistentClass.isInherited()) { IdentifierGenerator ig = persistentClass.getIdentifier().createIdentifierGenerator( metadata.getIdentifierGeneratorFactory(), database.getDialect(), null,
PersisterCreationContext creationContext) throws MappingException, CacheException { final Database database = creationContext.getMetadata().getDatabase(); final JdbcEnvironment jdbcEnvironment = database.getJdbcEnvironment(); creationContext.getMetadata().getIdentifierGeneratorFactory(), factory.getDialect(), factory.getSettings().getDefaultCatalogName(),
@Override public SessionFactory buildSessionFactory() { return delegate.buildSessionFactory(); }