Java 类org.hibernate.metamodel.source.MetadataImplementor 实例源码

项目:lams    文件:MappingDocument.java   
private LocalBindingContextImpl(MetadataImplementor metadata) {
    this.metadata = metadata;
    this.localMappingDefaults = new OverriddenMappingDefaults(
            metadata.getMappingDefaults(),
            hbmJaxbRoot.getRoot().getPackage(),
            hbmJaxbRoot.getRoot().getSchema(),
            hbmJaxbRoot.getRoot().getCatalog(),
            null,
            null,
            hbmJaxbRoot.getRoot().getDefaultCascade(),
            hbmJaxbRoot.getRoot().getDefaultAccess(),
            hbmJaxbRoot.getRoot().isDefaultLazy()
    );
    if ( hbmJaxbRoot.getRoot().getMeta() == null || hbmJaxbRoot.getRoot().getMeta().isEmpty() ) {
        this.metaAttributeContext = new MetaAttributeContext( metadata.getGlobalMetaAttributeContext() );
    }
    else {
        this.metaAttributeContext = Helper.extractMetaAttributeContext(
                hbmJaxbRoot.getRoot().getMeta(),
                true,
                metadata.getGlobalMetaAttributeContext()
        );
    }
}
项目:lams    文件:IdGeneratorBinder.java   
private static void bindGenericGenerator(MetadataImplementor metadata, AnnotationInstance generator) {
    String name = JandexHelper.getValue( generator, "name", String.class );
    Map<String, String> parameterMap = new HashMap<String, String>();
    AnnotationInstance[] parameterAnnotations = JandexHelper.getValue(
            generator,
            "parameters",
            AnnotationInstance[].class
    );
    for ( AnnotationInstance parameterAnnotation : parameterAnnotations ) {
        parameterMap.put(
                JandexHelper.getValue( parameterAnnotation, "name", String.class ),
                JandexHelper.getValue( parameterAnnotation, "value", String.class )
        );
    }
    metadata.addIdGenerator(
            new IdGenerator(
                    name,
                    JandexHelper.getValue( generator, "strategy", String.class ),
                    parameterMap
            )
    );
    LOG.tracef( "Add generic generator with name: %s", name );
}
项目:lams    文件:FilterDefBinder.java   
private static void bind(MetadataImplementor metadata, AnnotationInstance filterDef) {
    String name = JandexHelper.getValue( filterDef, "name", String.class );
    Map<String, Type> prms = new HashMap<String, Type>();
    for ( AnnotationInstance prm : JandexHelper.getValue( filterDef, "parameters", AnnotationInstance[].class ) ) {
        prms.put(
                JandexHelper.getValue( prm, "name", String.class ),
                metadata.getTypeResolver().heuristicType( JandexHelper.getValue( prm, "type", String.class ) )
        );
    }
    metadata.addFilterDefinition(
            new FilterDefinition(
                    name,
                    JandexHelper.getValue( filterDef, "defaultCondition", String.class ),
                    prms
            )
    );
    LOG.debugf( "Binding filter definition: %s", name );
}
项目:lams    文件:FetchProfileBinder.java   
private static void bind(MetadataImplementor metadata, AnnotationInstance fetchProfile) {
    String name = JandexHelper.getValue( fetchProfile, "name", String.class );
    Set<Fetch> fetches = new HashSet<Fetch>();
    AnnotationInstance[] overrideAnnotations = JandexHelper.getValue(
            fetchProfile,
            "fetchOverrides",
            AnnotationInstance[].class
    );
    for ( AnnotationInstance override : overrideAnnotations ) {
        FetchMode fetchMode = JandexHelper.getEnumValue( override, "mode", FetchMode.class );
        if ( !fetchMode.equals( org.hibernate.annotations.FetchMode.JOIN ) ) {
            throw new MappingException( "Only FetchMode.JOIN is currently supported" );
        }
        final String entityName = JandexHelper.getValue( override, "entity", String.class );
        final String associationName = JandexHelper.getValue( override, "association", String.class );
        fetches.add( new Fetch( entityName, associationName, fetchMode.toString().toLowerCase() ) );
    }
    metadata.addFetchProfile( new FetchProfile( name, fetches ) );
}
项目:lams    文件:SchemaExport.java   
public SchemaExport(MetadataImplementor metadata) {
    ServiceRegistry serviceRegistry = metadata.getServiceRegistry();
    this.connectionHelper = new SuppliedConnectionProviderConnectionHelper(
            serviceRegistry.getService( ConnectionProvider.class )
    );
       JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class );
    this.sqlStatementLogger = jdbcServices.getSqlStatementLogger();
    this.formatter = ( sqlStatementLogger.isFormat() ? FormatStyle.DDL : FormatStyle.NONE ).getFormatter();
    this.sqlExceptionHelper = jdbcServices.getSqlExceptionHelper();

    this.importFiles = ConfigurationHelper.getString(
            AvailableSettings.HBM2DDL_IMPORT_FILES,
            serviceRegistry.getService( ConfigurationService.class ).getSettings(),
            DEFAULT_IMPORT_FILE
    );

    final Dialect dialect = jdbcServices.getDialect();
    this.dropSQL = metadata.getDatabase().generateDropSchemaScript( dialect );
    this.createSQL = metadata.getDatabase().generateSchemaCreationScript( dialect );
}
项目:lams    文件:SessionFactoryServiceRegistryImpl.java   
@SuppressWarnings( {"unchecked"})
public SessionFactoryServiceRegistryImpl(
        ServiceRegistryImplementor parent,
        SessionFactoryImplementor sessionFactory,
        MetadataImplementor metadata) {
    super( parent );

    this.sessionFactory = sessionFactory;
    this.configuration = null;
    this.metadata = metadata;

    // for now, just use the standard initiator list
    for ( SessionFactoryServiceInitiator initiator : StandardSessionFactoryServiceInitiators.LIST ) {
        // create the bindings up front to help identify to which registry services belong
        createServiceBinding( initiator );
    }
}
项目:lams    文件:TypeDefBinder.java   
private static void bind(MetadataImplementor metadata, AnnotationInstance typeDefAnnotation) {
    String name = JandexHelper.getValue( typeDefAnnotation, "name", String.class );
    String defaultForType = JandexHelper.getValue( typeDefAnnotation, "defaultForType", String.class );
    String typeClass = JandexHelper.getValue( typeDefAnnotation, "typeClass", String.class );

    boolean noName = StringHelper.isEmpty( name );
    boolean noDefaultForType = defaultForType == null || defaultForType.equals( void.class.getName() );

    if ( noName && noDefaultForType ) {
        throw new AnnotationException(
                "Either name or defaultForType (or both) attribute should be set in TypeDef having typeClass "
                        + typeClass
        );
    }

    Map<String, String> parameterMaps = new HashMap<String, String>();
    AnnotationInstance[] parameterAnnotations = JandexHelper.getValue(
            typeDefAnnotation,
            "parameters",
            AnnotationInstance[].class
    );
    for ( AnnotationInstance parameterAnnotation : parameterAnnotations ) {
        parameterMaps.put(
                JandexHelper.getValue( parameterAnnotation, "name", String.class ),
                JandexHelper.getValue( parameterAnnotation, "value", String.class )
        );
    }

    if ( !noName ) {
        bind( name, typeClass, parameterMaps, metadata );
    }
    if ( !noDefaultForType ) {
        bind( defaultForType, typeClass, parameterMaps, metadata );
    }
}
项目:lams    文件:TypeDefBinder.java   
private static void bind(
        String name,
        String typeClass,
        Map<String, String> prms,
        MetadataImplementor metadata) {
    LOG.debugf( "Binding type definition: %s", name );
    metadata.addTypeDefinition( new TypeDef( name, typeClass, prms ) );
}
项目:lams    文件:TableBinder.java   
private static void bind(MetadataImplementor metadata, AnnotationInstance tableAnnotation) {
    String tableName = JandexHelper.getValue( tableAnnotation, "appliesTo", String.class );
    ObjectName objectName = new ObjectName( tableName );
    Schema schema = metadata.getDatabase().getSchema( objectName.getSchema(), objectName.getCatalog() );
    Table table = schema.locateTable( objectName.getName() );
    if ( table != null ) {
        bindHibernateTableAnnotation( table, tableAnnotation );
    }
}
项目:lams    文件:AnnotationBindingContextImpl.java   
public AnnotationBindingContextImpl(MetadataImplementor metadata, Index index) {
    this.metadata = metadata;
    this.classLoaderService = new ValueHolder<ClassLoaderService>(
            new ValueHolder.DeferredInitializer<ClassLoaderService>() {
                @Override
                public ClassLoaderService initialize() {
                    return AnnotationBindingContextImpl.this.metadata
                            .getServiceRegistry()
                            .getService( ClassLoaderService.class );
                }
            }
    );
    this.index = index;
}
项目:lams    文件:PersisterFactoryImpl.java   
@Override
@SuppressWarnings( {"unchecked"})
public CollectionPersister createCollectionPersister(
        MetadataImplementor metadata,
        PluralAttributeBinding collectionMetadata,
        CollectionRegionAccessStrategy cacheAccessStrategy,
        SessionFactoryImplementor factory) throws HibernateException {
    Class<? extends CollectionPersister> persisterClass = collectionMetadata.getCollectionPersisterClass();
    if ( persisterClass == null ) {
        persisterClass = serviceRegistry.getService( PersisterClassResolver.class ).getCollectionPersisterClass( collectionMetadata );
    }

    return create( persisterClass, COLLECTION_PERSISTER_CONSTRUCTOR_ARGS_NEW, metadata, collectionMetadata, cacheAccessStrategy, factory );
}
项目:lams    文件:NativeQueryInterpreterInitiator.java   
@Override
public NativeQueryInterpreter initiateService(
        SessionFactoryImplementor sessionFactory,
        MetadataImplementor metadata,
        ServiceRegistryImplementor registry) {
    return NativeQueryInterpreterStandardImpl.INSTANCE;
}
项目:lams    文件:StatisticsInitiator.java   
@Override
public StatisticsImplementor initiateService(
        SessionFactoryImplementor sessionFactory,
        MetadataImplementor metadata,
        ServiceRegistryImplementor registry) {
    ConfigurationService configurationService =  registry.getService( ConfigurationService.class );
    final Object configValue = configurationService.getSetting( STATS_BUILDER, null );
    return initiateServiceInternal( sessionFactory, configValue, registry );
}
项目:lams    文件:JaccIntegrator.java   
@Override
public void integrate(
        MetadataImplementor metadata,
        SessionFactoryImplementor sessionFactory,
        SessionFactoryServiceRegistry serviceRegistry) {
    doIntegration( sessionFactory.getProperties(), null, serviceRegistry );
}
项目:lams    文件:EventListenerServiceInitiator.java   
@Override
public EventListenerRegistry initiateService(
        SessionFactoryImplementor sessionFactory,
        MetadataImplementor metadata,
        ServiceRegistryImplementor registry) {
    return new EventListenerRegistryImpl();
}
项目:jspresso-ce    文件:JspressoHibernateIntegrator.java   
/**
 * Appends the {@link LifecyclePostLoadEventListener}.
 * <p>
 * {@inheritDoc}
 */
@Override
public void integrate(MetadataImplementor metadata,
    SessionFactoryImplementor sessionFactory,
    SessionFactoryServiceRegistry serviceRegistry) {
  serviceRegistry.getService(EventListenerRegistry.class)
      .getEventListenerGroup(EventType.POST_LOAD)
      .appendListener(postLoadListener);
}
项目:lams    文件:BeanValidationIntegrator.java   
@Override
public void integrate(
        MetadataImplementor metadata,
        SessionFactoryImplementor sessionFactory,
        SessionFactoryServiceRegistry serviceRegistry ) {
}
项目:lams    文件:Binder.java   
public Binder(MetadataImplementor metadata, List<String> processedEntityNames) {
    this.metadata = metadata;
    this.processedEntityNames = processedEntityNames;
}
项目:lams    文件:MappingDocument.java   
public MappingDocument(JaxbRoot<JaxbHibernateMapping> hbmJaxbRoot, MetadataImplementor metadata) {
    this.hbmJaxbRoot = hbmJaxbRoot;
    this.mappingLocalBindingContext = new LocalBindingContextImpl( metadata );

}
项目:lams    文件:MappingDocument.java   
@Override
public MetadataImplementor getMetadataImplementor() {
    return metadata;
}
项目:lams    文件:HbmMetadataSourceProcessorImpl.java   
public HbmMetadataSourceProcessorImpl(MetadataImplementor metadata) {
    this.metadata = metadata;
}
项目:lams    文件:HibernateMappingProcessor.java   
public HibernateMappingProcessor(MetadataImplementor metadata, MappingDocument mappingDocument) {
    this.metadata = metadata;
    this.mappingDocument = mappingDocument;
}
项目:lams    文件:IdentifierGeneratorResolver.java   
IdentifierGeneratorResolver(MetadataImplementor metadata) {
    this.metadata = metadata;
}
项目:lams    文件:IdentifierGeneratorResolver.java   
private ObjectNameNormalizerImpl(MetadataImplementor metadata ) {
    this.useQuotedIdentifiersGlobally = metadata.isGloballyQuotedIdentifiers();
    this.namingStrategy = metadata.getNamingStrategy();
}
项目:lams    文件:AssociationResolver.java   
AssociationResolver(MetadataImplementor metadata) {
    this.metadata = metadata;
}
项目:lams    文件:HibernateTypeResolver.java   
HibernateTypeResolver(MetadataImplementor metadata) {
    this.metadata = metadata;
}
项目:lams    文件:MetadataImpl.java   
@Override
public MetadataImplementor getMetadataImplementor() {
    return this;
}
项目:lams    文件:SessionFactoryBuilderImpl.java   
SessionFactoryBuilderImpl(MetadataImplementor metadata) {
    this.metadata = metadata;
    options = new SessionFactoryOptionsImpl( metadata.getOptions().getServiceRegistry() );
}
项目:lams    文件:EntityBindingContext.java   
@Override
public MetadataImplementor getMetadataImplementor() {
    return contextDelegate.getMetadataImplementor();
}
项目:lams    文件:IdGeneratorBinder.java   
private static void bindSequenceGenerator(MetadataImplementor metadata, AnnotationInstance generator) {
    String name = JandexHelper.getValue( generator, "name", String.class );
    Map<String, String> parameterMap = new HashMap<String, String>();
    addStringParameter( generator, "sequenceName", parameterMap, SequenceStyleGenerator.SEQUENCE_PARAM );
    boolean useNewIdentifierGenerators = metadata.getOptions().useNewIdentifierGenerators();
    String strategy = EnumConversionHelper.generationTypeToGeneratorStrategyName(
            GenerationType.SEQUENCE,
            useNewIdentifierGenerators
    );
    if ( useNewIdentifierGenerators ) {
        addStringParameter( generator, "catalog", parameterMap, PersistentIdentifierGenerator.CATALOG );
        addStringParameter( generator, "schema", parameterMap, PersistentIdentifierGenerator.SCHEMA );
        parameterMap.put(
                SequenceStyleGenerator.INCREMENT_PARAM,
                String.valueOf( JandexHelper.getValue( generator, "allocationSize", Integer.class ) )
        );
        parameterMap.put(
                SequenceStyleGenerator.INITIAL_PARAM,
                String.valueOf( JandexHelper.getValue( generator, "initialValue", Integer.class ) )
        );
    }
    else {
        if ( JandexHelper.getValue( generator, "initialValue", Integer.class ) != 1 ) {
            LOG.unsupportedInitialValue( AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS );
        }
        parameterMap.put(
                SequenceHiLoGenerator.MAX_LO,
                String.valueOf( JandexHelper.getValue( generator, "allocationSize", Integer.class ) - 1 )
        );
    }
    metadata.addIdGenerator( new IdGenerator( name, strategy, parameterMap ) );
    LOG.tracef( "Add sequence generator with name: %s", name );
}
项目:lams    文件:IdGeneratorBinder.java   
private static void bindTableGenerator(MetadataImplementor metadata, AnnotationInstance generator) {
    String name = JandexHelper.getValue( generator, "name", String.class );
    Map<String, String> parameterMap = new HashMap<String, String>();
    addStringParameter( generator, "catalog", parameterMap, PersistentIdentifierGenerator.CATALOG );
    addStringParameter( generator, "schema", parameterMap, PersistentIdentifierGenerator.SCHEMA );
    boolean useNewIdentifierGenerators = metadata.getOptions().useNewIdentifierGenerators();
    String strategy = EnumConversionHelper.generationTypeToGeneratorStrategyName(
            GenerationType.TABLE,
            useNewIdentifierGenerators
    );
    if ( useNewIdentifierGenerators ) {
        parameterMap.put( TableGenerator.CONFIG_PREFER_SEGMENT_PER_ENTITY, "true" );
        addStringParameter( generator, "table", parameterMap, TableGenerator.TABLE_PARAM );
        addStringParameter( generator, "pkColumnName", parameterMap, TableGenerator.SEGMENT_COLUMN_PARAM );
        addStringParameter( generator, "pkColumnValue", parameterMap, TableGenerator.SEGMENT_VALUE_PARAM );
        addStringParameter( generator, "valueColumnName", parameterMap, TableGenerator.VALUE_COLUMN_PARAM );
        parameterMap.put(
                TableGenerator.INCREMENT_PARAM,
                String.valueOf( JandexHelper.getValue( generator, "allocationSize", String.class ) )
        );
        parameterMap.put(
                TableGenerator.INITIAL_PARAM,
                String.valueOf( JandexHelper.getValue( generator, "initialValue", String.class ) + 1 )
        );
    }
    else {
        addStringParameter( generator, "table", parameterMap, MultipleHiLoPerTableGenerator.ID_TABLE );
        addStringParameter( generator, "pkColumnName", parameterMap, MultipleHiLoPerTableGenerator.PK_COLUMN_NAME );
        addStringParameter( generator, "pkColumnValue", parameterMap, MultipleHiLoPerTableGenerator.PK_VALUE_NAME );
        addStringParameter( generator, "valueColumnName", parameterMap, MultipleHiLoPerTableGenerator.VALUE_COLUMN_NAME );
        parameterMap.put(
                TableHiLoGenerator.MAX_LO,
                String.valueOf( JandexHelper.getValue( generator, "allocationSize", Integer.class ) - 1 )
        );
    }
    if ( JandexHelper.getValue( generator, "uniqueConstraints", AnnotationInstance[].class ).length > 0 ) {
        LOG.ignoringTableGeneratorConstraints( name );
    }
    metadata.addIdGenerator( new IdGenerator( name, strategy, parameterMap ) );
    LOG.tracef( "Add table generator with name: %s", name );
}
项目:lams    文件:QueryBinder.java   
/**
 * Binds {@link javax.persistence.NamedQuery} as well as {@link org.hibernate.annotations.NamedQuery}.
 *
 * @param metadata the current metadata
 * @param annotation the named query annotation
 */
private static void bindNamedQuery(MetadataImplementor metadata, AnnotationInstance annotation) {
    String name = JandexHelper.getValue( annotation, "name", String.class );
    if ( StringHelper.isEmpty( name ) ) {
        throw new AnnotationException( "A named query must have a name when used in class or package level" );
    }

    String query = JandexHelper.getValue( annotation, "query", String.class );

    AnnotationInstance[] hints = JandexHelper.getValue( annotation, "hints", AnnotationInstance[].class );

    String cacheRegion = getString( hints, QueryHints.CACHE_REGION );
    if ( StringHelper.isEmpty( cacheRegion ) ) {
        cacheRegion = null;
    }

    Integer timeout = getTimeout( hints, query );
    if ( timeout != null && timeout < 0 ) {
        timeout = null;
    }

    Integer fetchSize = getInteger( hints, QueryHints.FETCH_SIZE, name );
    if ( fetchSize != null && fetchSize < 0 ) {
        fetchSize = null;
    }

    String comment = getString( hints, QueryHints.COMMENT );
    if ( StringHelper.isEmpty( comment ) ) {
        comment = null;
    }

    metadata.addNamedQuery(
            new NamedQueryDefinitionBuilder().setName( name ).setQuery( query ).setCacheable(
                    getBoolean(
                            hints,
                            QueryHints.CACHEABLE,
                            name
                    )
            ).setCacheRegion( cacheRegion ).setTimeout( timeout ).setFetchSize( fetchSize ).setFlushMode(
                    getFlushMode( hints, QueryHints.FLUSH_MODE, name )
            ).setCacheMode( getCacheMode( hints, QueryHints.CACHE_MODE, name ) ).setReadOnly(
                    getBoolean(
                            hints,
                            QueryHints.READ_ONLY,
                            name
                    )
            ).setComment( comment ).setParameterTypes( null ).createNamedQueryDefinition()
    );
    LOG.debugf( "Binding named query: %s => %s", name, query );
}
项目:lams    文件:AnnotationBindingContextImpl.java   
@Override
public MetadataImplementor getMetadataImplementor() {
    return metadata;
}
项目:lams    文件:CacheInitiator.java   
@Override
public CacheImplementor initiateService(SessionFactoryImplementor sessionFactory, MetadataImplementor metadata, ServiceRegistryImplementor registry) {
    return new CacheImpl( sessionFactory );
}
项目:lams    文件:SessionFactoryServiceRegistryFactoryImpl.java   
@Override
public SessionFactoryServiceRegistryImpl buildServiceRegistry(
        SessionFactoryImplementor sessionFactory,
        MetadataImplementor metadata) {
    return new SessionFactoryServiceRegistryImpl( theBasicServiceRegistry, sessionFactory, metadata );
}
项目:lams    文件:CollectionCacheInvalidator.java   
@Override
public void integrate(MetadataImplementor metadata, SessionFactoryImplementor sessionFactory,
        SessionFactoryServiceRegistry serviceRegistry) {
    integrate( serviceRegistry, sessionFactory );
}
项目:cibet    文件:CibetIntegrator.java   
@Override
public void integrate(MetadataImplementor arg0, SessionFactoryImplementor arg1, SessionFactoryServiceRegistry arg2) {
   if (enversConfiguration != null) {
      enversConfiguration.destroy();
   }
}
项目:hibernate-conventions    文件:ConventionsIntegrator.java   
public void integrate(
        MetadataImplementor metadata,
        SessionFactoryImplementor sessionFactory,
        SessionFactoryServiceRegistry serviceRegistry) {
}
项目:ix3    文件:IntegratorImplRuleEngine.java   
@Override
public void integrate(MetadataImplementor mi, SessionFactoryImplementor sfi, SessionFactoryServiceRegistry sfsr) {
    final EventListenerRegistry eventListenerRegistry = sfsr.getService(EventListenerRegistry.class);

    prependListeners(eventListenerRegistry);

}
项目:lams    文件:PersisterFactory.java   
/**
 * Create a collection persister instance.
 *
 * @param metadata The metadata
 * @param model The O/R mapping metamodel definition for the collection
 * @param cacheAccessStrategy The caching strategy for this collection
 * @param factory The session factory
 *
 * @return An appropriate collection persister instance.
 *
 * @throws HibernateException Indicates a problem building the persister.
 */
public CollectionPersister createCollectionPersister(
        MetadataImplementor metadata,
        PluralAttributeBinding model,
        CollectionRegionAccessStrategy cacheAccessStrategy,
        SessionFactoryImplementor factory) throws HibernateException;