public boolean canProcessImmediately() { // We can process the FK immediately if it is a reference to the associated // entity's PK. // // There is an assumption here that the columns making up the FK have been bound. // We assume the caller checks that final PersistentClass referencedEntityBinding = mappingDocument.getMetadataCollector() .getEntityBinding( referencedEntityName ); return referencedEntityBinding != null && referencedEntityAttributeName != null; } }
private void bindUnionSubclassEntities( EntitySource entitySource, PersistentClass superEntityDescriptor) { for ( IdentifiableTypeSource subType : entitySource.getSubTypes() ) { final UnionSubclass subEntityDescriptor = new UnionSubclass( superEntityDescriptor, metadataBuildingContext ); bindUnionSubclassEntity( (SubclassEntitySourceImpl) subType, subEntityDescriptor ); superEntityDescriptor.addSubclass( subEntityDescriptor ); entitySource.getLocalMetadataBuildingContext().getMetadataCollector().addEntityBinding( subEntityDescriptor ); } }
@Override public void processQueryRenames() { for ( JaxbHbmClassRenameType renameBinding : documentRoot.getImport() ) { final String name = qualifyClassName( renameBinding.getClazz() ); final String rename = renameBinding.getRename() == null ? StringHelper.unqualify( name ) : renameBinding.getRename(); getMetadataCollector().addImport( rename, name ); log.debugf( "Import (query rename): %s -> %s", rename, name ); } }
void addAttributeConverter(ConverterDescriptor descriptor);
void addIndex(String indexName, boolean inSecondPass) { IndexOrUniqueKeySecondPass secondPass = new IndexOrUniqueKeySecondPass( indexName, this, context, false ); if ( inSecondPass ) { secondPass.doSecondPass( context.getMetadataCollector().getEntityBindingMap() ); } else { context.getMetadataCollector().addSecondPass( secondPass ); } }
public void linkWithValue() { if ( columns[0].isNameDeferred() && !buildingContext.getMetadataCollector().isInSecondPass() && referencedEntityName != null ) { buildingContext.getMetadataCollector().addSecondPass( new PkDrivenByDefaultMapsIdSecondPass( referencedEntityName, (Ejb3JoinColumn[]) columns, simpleValue ) ); } else { for ( Ejb3Column column : columns ) { column.linkWithValue( simpleValue ); } } }
@Override public void contribute(InFlightMetadataCollector metadataCollector, IndexView jandexIndex) { // Skip if already registered if (metadataCollector.getEntityBinding("com.blazebit.persistence.impl.function.entity.ValuesEntity") != null) { return; } MetadataBuildingOptions options = metadataCollector.getMetadataBuildingOptions(); final ClassLoaderService classLoaderService = options.getServiceRegistry().getService( ClassLoaderService.class ); final ClassLoaderAccess classLoaderAccess = new ClassLoaderAccessImpl( options.getTempClassLoader(), classLoaderService ); MetadataBuildingContext metadataBuildingContext = new MetadataBuildingContextRootImpl( options, classLoaderAccess, metadataCollector); addEntity("com.blazebit.persistence.impl.function.entity.ValuesEntity", metadataBuildingContext); }
@Override public void contribute(InFlightMetadataCollector metadataCollector, IndexView jandexIndex) { ServiceBinding.ServiceLifecycleOwner lifecycleOwner = (ServiceBinding.ServiceLifecycleOwner) metadataCollector.getBootstrapContext().getServiceRegistry(); lifecycleOwner.configureService(new ServiceBinding<>(lifecycleOwner, Hibernate53MetadataContributor.class, this)); Object existingStrategy = configurationValues.get("hibernate.hql.bulk_id_strategy"); if (existingStrategy == null) { JdbcServices jdbcService = metadataCollector.getBootstrapContext().getServiceRegistry().getService(JdbcServices.class); MultiTableBulkIdStrategy defaultMultiTableBulkIdStrategy = jdbcService.getDialect().getDefaultMultiTableBulkIdStrategy(); configurationValues.put("hibernate.hql.bulk_id_strategy", new CustomMultiTableBulkIdStrategy(defaultMultiTableBulkIdStrategy)); } else { LOG.warning("Can't replace hibernate.hql.bulk_id_strategy because it was overridden by the user with: " + existingStrategy); } // Skip if already registered if (metadataCollector.getEntityBinding("com.blazebit.persistence.impl.function.entity.ValuesEntity") != null) { return; } MetadataBuildingContext metadataBuildingContext = new MetadataBuildingContextRootImpl( metadataCollector.getBootstrapContext(), metadataCollector.getMetadataBuildingOptions(), metadataCollector); addEntity("com.blazebit.persistence.impl.function.entity.ValuesEntity", metadataBuildingContext); }
for (Iterator<Table> iter = metadataCollector.collectTableMappings().iterator(); iter.hasNext();) { Table table = iter.next(); if (table.getCatalog() != null && table.getCatalog().equals(defaultCatalog)) { rc.setTable(table); try { metadataCollector.addEntityBinding(rc); } catch(DuplicateMappingException dme) { PersistentClass class1 = metadataCollector.getEntityBinding(dme.getName()); Table table2 = class1.getTable(); throw new JDBCBinderException("Duplicate class name '" + rc.getEntityName() + "' generated for '" + table + "'. Same name where generated for '" + table2 + "'"); metadataCollector.addImport( rc.getEntityName(), rc.getEntityName() );
private static class AssociationTableNameSource implements ObjectNameSource { private final String explicitName; private final String logicalName; private AssociationTableNameSource(String explicitName, String logicalName) { this.explicitName = explicitName; this.logicalName = logicalName; } public String getExplicitName() { return explicitName; } public String getLogicalName() { return logicalName; } }
sourceDocument.getMetadataCollector().addImport( entitySource.getEntityNamingSource().getEntityName(), entitySource.getEntityNamingSource().getEntityName() sourceDocument.getMetadataCollector().addImport( StringHelper.unqualify( entitySource.getEntityNamingSource().getEntityName() ), entitySource.getEntityNamingSource().getEntityName() final JdbcEnvironment jdbcEnvironment = sourceDocument.getMetadataCollector().getDatabase().getJdbcEnvironment(); String condition = filterSource.getCondition(); if ( condition == null ) { final FilterDefinition filterDefinition = sourceDocument.getMetadataCollector().getFilterDefinition( filterSource.getName() ); if ( filterDefinition != null ) { condition = filterDefinition.getDefaultFilterCondition();
public void doSecondPass(Map persistentClasses) throws MappingException { org.hibernate.mapping.FetchProfile profile = buildingContext.getMetadataCollector().getFetchProfile( fetchProfileName ); if ( profile != null ) { if ( profile.getSource() != MetadataSource.ANNOTATIONS ) { return; } } else { profile = new org.hibernate.mapping.FetchProfile( fetchProfileName, MetadataSource.ANNOTATIONS ); buildingContext.getMetadataCollector().addFetchProfile( profile ); } PersistentClass clazz = buildingContext.getMetadataCollector().getEntityBinding( fetch.entity().getName() ); // throws MappingException in case the property does not exist clazz.getProperty( fetch.association() ); profile.addFetch( fetch.entity().getName(), fetch.association(), fetch.mode().toString().toLowerCase(Locale.ROOT) ); } }
private void addMappedSuperClassInMetadata(PersistentClass persistentClass) { //add @MappedSuperclass in the metadata // classes from 0 to n-1 are @MappedSuperclass and should be linked org.hibernate.mapping.MappedSuperclass mappedSuperclass = null; final InheritanceState superEntityState = InheritanceState.getInheritanceStateOfSuperEntity( clazz, inheritanceStatePerClass ); PersistentClass superEntity = superEntityState != null ? buildingContext.getMetadataCollector().getEntityBinding( superEntityState.getClazz().getName() ) : null; final int lastMappedSuperclass = classesToProcessForMappedSuperclass.size() - 1; for ( int index = 0; index < lastMappedSuperclass; index++ ) { org.hibernate.mapping.MappedSuperclass parentSuperclass = mappedSuperclass; final Class<?> type = buildingContext.getBootstrapContext().getReflectionManager() .toClass( classesToProcessForMappedSuperclass.get( index ) ); //add MAppedSuperclass if not already there mappedSuperclass = buildingContext.getMetadataCollector().getMappedSuperclass( type ); if ( mappedSuperclass == null ) { mappedSuperclass = new org.hibernate.mapping.MappedSuperclass( parentSuperclass, superEntity ); mappedSuperclass.setMappedClass( type ); buildingContext.getMetadataCollector().addMappedSuperclass( type, mappedSuperclass ); } } if ( mappedSuperclass != null ) { persistentClass.setSuperMappedSuperclass( mappedSuperclass ); } }
if ( logicalReferencedColumn != null ) { return getBuildingContext().getMetadataCollector() .getDatabase() .toIdentifier( logicalReferencedColumn ); .getEntityBinding( mappedByEntityName ); final Property mappedByProperty = mappedByEntityBinding.getProperty( mappedByPropertyName ); final SimpleValue value = (SimpleValue) mappedByProperty.getValue(); .getDatabase() .toIdentifier( ( (Column) selectable ).getQuotedName() );
AnnotatedClassType classType = metadataCollector.getClassType( clazzToProcess ); ? metadataCollector.getEntityTableXref( superEntity.getEntityName() ) : null; metadataCollector.getEntityTableXref( superEntity.getEntityName() ) ); final JoinedSubclass jsc = (JoinedSubclass) persistentClass; SimpleValue key = new DependantValue( metadataCollector.getTypeConfiguration().getMetadataBuildingContext(), jsc.getTable(), jsc.getIdentifier() metadataCollector.addSecondPass( new JoinedSubclassFkSecondPass( jsc, inheritanceJoinedColumns, context ) ); metadataCollector.addSecondPass( new CreateKeySecondPass( jsc ) ); metadataCollector.addSecondPass( new CreateKeySecondPass( rootClass ) ); metadataCollector.addEntityMappingHierarchy( rootClass.getEntityMappingHierarchy() ); metadataCollector.addEntityBinding( persistentClass ); metadataCollector.addSecondPass( new SecondaryTableSecondPass(
private void registerSecondPass(SecondPass secondPass, MetadataBuildingContext context) { context.getMetadataCollector().addSecondPass( secondPass ); }
AnnotatedClassType classType = context.getMetadataCollector().getClassType( clazzToProcess ); ? context.getMetadataCollector().getEntityTableXref( superEntity.getEntityName() ) : null; context.getMetadataCollector().getEntityTableXref( superEntity.getEntityName() ) ); context.getMetadataCollector().addSecondPass( new JoinedSubclassFkSecondPass( jsc, inheritanceJoinedColumns, key, context ) ); context.getMetadataCollector().addSecondPass( new CreateKeySecondPass( jsc ) ); context.getMetadataCollector().addSecondPass( new CreateKeySecondPass( rootClass ) ); context.getMetadataCollector().addEntityBinding( persistentClass ); context.getMetadataCollector().addSecondPass( new SecondaryTableSecondPass( entityBinder,
@Override public Identifier determineImplicitName(LocalMetadataBuildingContext context) { return context.getMetadataCollector().getDatabase().toIdentifier( Collection.DEFAULT_ELEMENT_COLUMN_NAME ); } }
final TypeDefinition typeDef = buildingContext.getMetadataCollector().getTypeDefinition( explicitType ); if ( typeDef == null ) { collection.setTypeName( explicitType ); buildingContext.getMetadataCollector().addMappedBy( getCollectionType().getName(), mappedBy, propertyName ); buildingContext.getMetadataCollector().addSecondPass( sp, !isMappedBy ); buildingContext.getMetadataCollector().addSecondPass( sp, !isMappedBy ); buildingContext.getMetadataCollector().addCollectionBinding( collection );
Map<String, Join> joins = buildingContext.getMetadataCollector().getJoins( assocClass ); if ( associatedClass == null ) { throw new MappingException( PersistentClass referenced = buildingContext.getMetadataCollector().getEntityBinding( entityName ); Backref prop = new Backref(); prop.setName( '_' + fkJoinColumns[0].getPropertyName() + '_' + fkJoinColumns[0].getLogicalColumnName() + "Backref" );