@Override public Map<String, Object> getProperties() { return delegate.getProperties(); }
@Override protected StorageAccess createQueryResultsRegionStorageAccess(String regionName, SessionFactoryImplementor sessionFactory) { RMapCache<Object, Object> mapCache = getCache(regionName, sessionFactory.getProperties(), QUERY_DEF); return new RedissonStorage(mapCache, sessionFactory.getProperties(), QUERY_DEF); }
@Override protected StorageAccess createTimestampsRegionStorageAccess(String regionName, SessionFactoryImplementor sessionFactory) { RMapCache<Object, Object> mapCache = getCache(regionName, sessionFactory.getProperties(), TIMESTAMPS_DEF); return new RedissonStorage(mapCache, sessionFactory.getProperties(), TIMESTAMPS_DEF); }
private void applyEntityManagerSpecificProperties() { final Map<String, Object> properties = getFactory().getProperties(); for ( String key : ENTITY_MANAGER_SPECIFIC_PROPERTIES ) { if ( properties.containsKey( key ) ) { this.properties.put( key, properties.get( key ) ); } } }
@Override protected DomainDataStorageAccess createDomainDataStorageAccess(DomainDataRegionConfig regionConfig, DomainDataRegionBuildingContext buildingContext) { String defaultKey = null; if (!regionConfig.getCollectionCaching().isEmpty()) { defaultKey = COLLECTION_DEF; } else if (!regionConfig.getEntityCaching().isEmpty()) { defaultKey = ENTITY_DEF; } else if (!regionConfig.getNaturalIdCaching().isEmpty()) { defaultKey = NATURAL_ID_DEF; } else { throw new IllegalArgumentException("Unable to determine entity cache type!"); } RMapCache<Object, Object> mapCache = getCache(regionConfig.getRegionName(), buildingContext.getSessionFactory().getProperties(), defaultKey); return new RedissonStorage(mapCache, buildingContext.getSessionFactory().getProperties(), defaultKey); }
factory.getProperties() ); if ( maxParameterMetadataCount == null ) { maxParameterMetadataCount = ConfigurationHelper.getInt( Environment.QUERY_PLAN_CACHE_MAX_STRONG_REFERENCES, factory.getProperties(), DEFAULT_PARAMETER_METADATA_MAX_COUNT ); factory.getProperties() ); if ( maxQueryPlanCount == null ) { maxQueryPlanCount = ConfigurationHelper.getInt( Environment.QUERY_PLAN_CACHE_MAX_SOFT_REFERENCES, factory.getProperties(), DEFAULT_QUERY_PLAN_MAX_COUNT );
/** * Get the currently configured JDBC batch size either at the Session-level or SessionFactory-level. * * If the Session-level JDBC batch size was not configured, return the SessionFactory-level one. * * @return Session-level or or SessionFactory-level JDBC batch size. * * @since 5.2 * * @see org.hibernate.boot.spi.SessionFactoryOptions#getJdbcBatchSize * @see org.hibernate.boot.SessionFactoryBuilder#applyJdbcBatchSize */ default Integer getConfiguredJdbcBatchSize() { final Integer sessionJdbcBatchSize = getJdbcBatchSize(); return sessionJdbcBatchSize == null ? ConfigurationHelper.getInt( Environment.STATEMENT_BATCH_SIZE, getFactory().getProperties(), 1 ) : sessionJdbcBatchSize; } }
.determineJpaMetaModelPopulationSetting( sessionFactory.getProperties() ) != JpaStaticMetaModelPopulationSetting.DISABLED;
public EnabledCaching(SessionFactoryImplementor sessionFactory) { this.sessionFactory = sessionFactory; this.regionFactory = getSessionFactory().getSessionFactoryOptions().getServiceRegistry().getService( RegionFactory.class ); this.regionFactory.start( sessionFactory.getSessionFactoryOptions(), sessionFactory.getProperties() ); if ( getSessionFactory().getSessionFactoryOptions().isQueryCacheEnabled() ) { final TimestampsRegion timestampsRegion = regionFactory.buildTimestampsRegion( RegionFactory.DEFAULT_UPDATE_TIMESTAMPS_REGION_UNQUALIFIED_NAME, sessionFactory ); timestampsCache = sessionFactory.getSessionFactoryOptions() .getTimestampsCacheFactory() .buildTimestampsCache( this, timestampsRegion ); legacySecondLevelCacheNames.add( timestampsRegion.getName() ); final QueryResultsRegion queryResultsRegion = regionFactory.buildQueryResultsRegion( RegionFactory.DEFAULT_QUERY_RESULTS_REGION_UNQUALIFIED_NAME, sessionFactory ); regionsByName.put( queryResultsRegion.getName(), queryResultsRegion ); defaultQueryResultsCache = new QueryResultsCacheImpl( queryResultsRegion, timestampsCache ); } else { timestampsCache = new TimestampsCacheDisabledImpl(); defaultQueryResultsCache = null; } }
@Override public Map<String, Object> getProperties() { return delegate.getProperties(); }
/** * Get an instance of the HibernateBridge from a SessionFactory. */ public static HibernateBridge getHibernateBridge(final org.hibernate.SessionFactory sessionFactory) { if (sessionFactory == null) return null; // the special key=HibernateBridge.class property is set in associate() below return (HibernateBridge) ((org.hibernate.engine.spi.SessionFactoryImplementor) sessionFactory) .getProperties().get(HibernateBridge.class.getName()); }
/** * Associate the v5 SessionFactory with a HibernateBridge, by adding it as a property. * It's nice that the v5 SessionFactory.getProperties is public, because it allows us to * avoid using reflection. */ public static org.hibernate.SessionFactory associate( final org.hibernate.SessionFactory sessionFactory, final HibernateBridge hibernateBridge) { ((org.hibernate.engine.spi.SessionFactoryImplementor) sessionFactory).getProperties().put( HibernateBridge.class.getName(), hibernateBridge); return sessionFactory; } }
@Override public synchronized void register(SessionFactoryImplementor sessionFactory) { sessionFactories.add( sessionFactory ); Object persistenceUnitName = sessionFactory.getProperties().get( AvailableSettings.PERSISTENCE_UNIT_NAME ); if ( persistenceUnitName instanceof String ) { sessionFactoriesByPUName.put( (String) persistenceUnitName, sessionFactory ); } String name = sessionFactory.getName(); if ( name != null ) { sessionFactoriesByName.put( name, sessionFactory ); } }
private void applyEntityManagerSpecificProperties() { final Map<String, Object> properties = getFactory().getProperties(); for ( String key : ENTITY_MANAGER_SPECIFIC_PROPERTIES ) { if ( properties.containsKey( key ) ) { this.properties.put( key, properties.get( key ) ); } } }
public QueryPlanCache(SessionFactoryImplementor factory) { int maxStrongReferenceCount = ConfigurationHelper.getInt( Environment.QUERY_PLAN_CACHE_MAX_STRONG_REFERENCES, factory.getProperties(), SoftLimitMRUCache.DEFAULT_STRONG_REF_COUNT ); int maxSoftReferenceCount = ConfigurationHelper.getInt( Environment.QUERY_PLAN_CACHE_MAX_SOFT_REFERENCES, factory.getProperties(), SoftLimitMRUCache.DEFAULT_SOFT_REF_COUNT ); this.factory = factory; this.sqlParamMetadataCache = new SimpleMRUCache( maxStrongReferenceCount ); this.planCache = new SoftLimitMRUCache( maxStrongReferenceCount, maxSoftReferenceCount ); }
public QueryPlanCache(SessionFactoryImplementor factory) { int maxStrongReferenceCount = ConfigurationHelper.getInt( Environment.QUERY_PLAN_CACHE_MAX_STRONG_REFERENCES, factory.getProperties(), SoftLimitMRUCache.DEFAULT_STRONG_REF_COUNT ); int maxSoftReferenceCount = ConfigurationHelper.getInt( Environment.QUERY_PLAN_CACHE_MAX_SOFT_REFERENCES, factory.getProperties(), SoftLimitMRUCache.DEFAULT_SOFT_REF_COUNT ); this.factory = factory; this.sqlParamMetadataCache = new SimpleMRUCache( maxStrongReferenceCount ); this.planCache = new SoftLimitMRUCache( maxStrongReferenceCount, maxSoftReferenceCount ); }
public QueryPlanCacheImpl(SessionFactoryImplementor sessionFactory) { this.sessionFactory = sessionFactory; Integer maxQueryPlanCount = ConfigurationHelper.getInteger( Environment.QUERY_PLAN_CACHE_MAX_SIZE, sessionFactory.getProperties() ); if ( maxQueryPlanCount == null ) { maxQueryPlanCount = ConfigurationHelper.getInt( Environment.QUERY_PLAN_CACHE_MAX_SIZE, sessionFactory.getProperties(), DEFAULT_QUERY_PLAN_MAX_COUNT ); } queryPlanCache = new BoundedConcurrentHashMap( maxQueryPlanCount, 20, BoundedConcurrentHashMap.Eviction.LIRS ); sqmStatementCache = new BoundedConcurrentHashMap( maxQueryPlanCount, 20, BoundedConcurrentHashMap.Eviction.LIRS ); }
/** * Get the currently configured JDBC batch size either at the Session-level or SessionFactory-level. * * If the Session-level JDBC batch size was not configured, return the SessionFactory-level one. * * @return Session-level or or SessionFactory-level JDBC batch size. * * @since 5.2 * * @see org.hibernate.boot.spi.SessionFactoryOptions#getJdbcBatchSize * @see org.hibernate.boot.SessionFactoryBuilder#applyJdbcBatchSize */ default Integer getConfiguredJdbcBatchSize() { final Integer sessionJdbcBatchSize = getJdbcBatchSize(); return sessionJdbcBatchSize == null ? ConfigurationHelper.getInt( Environment.STATEMENT_BATCH_SIZE, getFactory().getProperties(), 1 ) : sessionJdbcBatchSize; } }
@Override public void initializeSchema(SchemaDefinitionContext context) { SessionFactoryImplementor sessionFactoryImplementor = context.getSessionFactory(); ServiceRegistryImplementor registry = sessionFactoryImplementor.getServiceRegistry(); DatastoreProvider provider = registry.getService( DatastoreProvider.class ); List<Sequence> sequences = sequences( context.getDatabase() ); createSequences( sequences, context.getAllIdSourceKeyMetadata(), provider ); createIndexesIfMissing( provider, indexSpecs ); createEntityConstraints( provider, context.getDatabase(), sessionFactoryImplementor.getProperties() ); }
public EnabledCaching(SessionFactoryImplementor sessionFactory) { this.sessionFactory = sessionFactory; this.regionFactory = getSessionFactory().getSessionFactoryOptions().getServiceRegistry().getService( RegionFactory.class ); this.regionFactory.start( sessionFactory.getSessionFactoryOptions(), sessionFactory.getProperties() ); if ( getSessionFactory().getSessionFactoryOptions().isQueryCacheEnabled() ) { final TimestampsRegion timestampsRegion = regionFactory.buildTimestampsRegion( RegionFactory.DEFAULT_UPDATE_TIMESTAMPS_REGION_UNQUALIFIED_NAME, sessionFactory ); timestampsCache = sessionFactory.getSessionFactoryOptions() .getTimestampsCacheFactory() .buildTimestampsCache( this, timestampsRegion ); legacySecondLevelCacheNames.add( timestampsRegion.getName() ); final QueryResultsRegion queryResultsRegion = regionFactory.buildQueryResultsRegion( RegionFactory.DEFAULT_QUERY_RESULTS_REGION_UNQUALIFIED_NAME, sessionFactory ); regionsByName.put( queryResultsRegion.getName(), queryResultsRegion ); defaultQueryResultsCache = new QueryResultsCacheImpl( queryResultsRegion, timestampsCache ); } else { timestampsCache = new TimestampsCacheDisabledImpl(); defaultQueryResultsCache = null; } }