Java 类org.hibernate.engine.spi.SessionFactoryImplementor 实例源码

项目:lams    文件:ConditionalParenthesisFunction.java   
@Override
public String render(Type firstArgumentType, List arguments, SessionFactoryImplementor sessionFactory) {
    final boolean hasArgs = !arguments.isEmpty();
    final StringBuilder buf = new StringBuilder( getName() );
    if ( hasArgs ) {
        buf.append( "(" );
        for ( int i = 0; i < arguments.size(); i++ ) {
            buf.append( arguments.get( i ) );
            if ( i < arguments.size() - 1 ) {
                buf.append( ", " );
            }
        }
        buf.append( ")" );
    }
    return buf.toString();
}
项目:hibernate-ogm-ignite    文件:IgniteTestHelper.java   
@Override
public long getNumberOfAssociations(SessionFactory sessionFactory) {
    int associationCount = 0;
    IgniteDatastoreProvider datastoreProvider = getProvider( sessionFactory );
    for ( CollectionPersister collectionPersister : ( (SessionFactoryImplementor) sessionFactory ).getCollectionPersisters().values() ) {
        AssociationKeyMetadata associationKeyMetadata = ( (OgmCollectionPersister) collectionPersister ).getAssociationKeyMetadata();
        if ( associationKeyMetadata.getAssociationKind() == AssociationKind.ASSOCIATION ) {
            IgniteCache<Object, BinaryObject> associationCache = getAssociationCache( sessionFactory, associationKeyMetadata );
            StringBuilder query = new StringBuilder( "SELECT " )
                                        .append( StringHelper.realColumnName( associationKeyMetadata.getColumnNames()[0] ) )
                                        .append( " FROM " ).append( associationKeyMetadata.getTable() );
            SqlFieldsQuery sqlQuery = datastoreProvider.createSqlFieldsQueryWithLog( query.toString(), null );
            Iterable<List<?>> queryResult = associationCache.query( sqlQuery );
            Set<Object> uniqs = new HashSet<>();
            for ( List<?> row : queryResult ) {
                Object value = row.get( 0 );
                if ( value != null ) {
                    uniqs.add( value );
                }
            }
            associationCount += uniqs.size();
        }
    }
    return associationCount;
}
项目:lams    文件:HibernateTraversableResolver.java   
private void addAssociationsToTheSetForOneProperty(String name, Type type, String prefix, SessionFactoryImplementor factory) {

        if ( type.isCollectionType() ) {
            CollectionType collType = (CollectionType) type;
            Type assocType = collType.getElementType( factory );
            addAssociationsToTheSetForOneProperty(name, assocType, prefix, factory);
        }
        //ToOne association
        else if ( type.isEntityType() || type.isAnyType() ) {
            associations.add( prefix + name );
        } else if ( type.isComponentType() ) {
            CompositeType componentType = (CompositeType) type;
            addAssociationsToTheSetForAllProperties(
                    componentType.getPropertyNames(),
                    componentType.getSubtypes(),
                    (prefix.equals( "" ) ? name : prefix + name) + ".",
                    factory);
        }
    }
项目:lams    文件:CollectionType.java   
@Override
public String getAssociatedEntityName(SessionFactoryImplementor factory)
        throws MappingException {
    try {

        QueryableCollection collectionPersister = (QueryableCollection) factory
                .getCollectionPersister( role );

        if ( !collectionPersister.getElementType().isEntityType() ) {
            throw new MappingException( 
                    "collection was not an association: " + 
                    collectionPersister.getRole() 
                );
        }

        return collectionPersister.getElementPersister().getEntityName();

    }
    catch (ClassCastException cce) {
        throw new MappingException( "collection role is not queryable " + role );
    }
}
项目:lams    文件:ComponentType.java   
@Override
public String toLoggableString(Object value, SessionFactoryImplementor factory)
        throws HibernateException {
    if ( value == null ) {
        return "null";
    }

    if ( entityMode == null ) {
        throw new ClassCastException( value.getClass().getName() );
    }
    Map<String,String> result = new HashMap<String, String>();
    Object[] values = getPropertyValues( value, entityMode );
    for ( int i = 0; i < propertyTypes.length; i++ ) {
        result.put( propertyNames[i], propertyTypes[i].toLoggableString( values[i], factory ) );
    }
    return StringHelper.unqualify( getName() ) + result.toString();
}
项目:lams    文件:AbstractEmptinessExpression.java   
@Override
public final String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
    final String entityName = criteriaQuery.getEntityName( criteria, propertyName );
    final String actualPropertyName = criteriaQuery.getPropertyName( propertyName );
    final String sqlAlias = criteriaQuery.getSQLAlias( criteria, propertyName );

    final SessionFactoryImplementor factory = criteriaQuery.getFactory();
    final QueryableCollection collectionPersister = getQueryableCollection( entityName, actualPropertyName, factory );

    final String[] collectionKeys = collectionPersister.getKeyColumnNames();
    final String[] ownerKeys = ( (Loadable) factory.getEntityPersister( entityName ) ).getIdentifierColumnNames();

    final String innerSelect = "(select 1 from " + collectionPersister.getTableName() + " where "
            + new ConditionFragment().setTableAlias( sqlAlias ).setCondition( ownerKeys, collectionKeys ).toFragmentString()
            + ")";

    return excludeEmpty()
            ? "exists " + innerSelect
            : "not exists " + innerSelect;
}
项目:lams    文件:CastFunction.java   
@Override
public String render(Type columnType, List args, SessionFactoryImplementor factory) throws QueryException {
    if ( args.size()!=2 ) {
        throw new QueryException( "cast() requires two arguments; found : " + args.size() );
    }
    final String type = (String) args.get( 1 );
    final int[] sqlTypeCodes = factory.getTypeResolver().heuristicType( type ).sqlTypes( factory );
    if ( sqlTypeCodes.length!=1 ) {
        throw new QueryException("invalid Hibernate type for cast()");
    }
    String sqlType = factory.getDialect().getCastTypeName( sqlTypeCodes[0] );
    if ( sqlType == null ) {
        //TODO: never reached, since getExplicitHibernateTypeName() actually throws an exception!
        sqlType = type;
    }
    return "cast(" + args.get( 0 ) + " as " + sqlType + ')';
}
项目:lams    文件:SubqueryExpression.java   
/**
 * Creates the inner query used to extract some useful information about types, since it is needed in both methods.
 *
 * @param criteriaQuery The criteria query
 * @param factory The session factory.
 */
private void createAndSetInnerQuery(CriteriaQuery criteriaQuery, SessionFactoryImplementor factory) {
    if ( innerQuery == null ) {
        //with two-deep subqueries, the same alias would get generated for
        //both using the old method (criteriaQuery.generateSQLAlias()), so
        //that is now used as a fallback if the main criteria alias isn't set
        String alias;
        if ( this.criteriaImpl.getAlias() == null ) {
            alias = criteriaQuery.generateSQLAlias();
        }
        else {
            alias = this.criteriaImpl.getAlias() + "_";
        }

        innerQuery = new CriteriaQueryTranslator(
                factory,
                criteriaImpl,
                criteriaImpl.getEntityOrClassName(),
                alias,
                criteriaQuery
            );

        params = innerQuery.getQueryParameters();
        types = innerQuery.getProjectedTypes();
    }
}
项目:lams    文件:JoinedSubclassEntityPersister.java   
private void associateSubclassNamesToSubclassTableIndexes(
        PersistentClass persistentClass,
        Set<String> classNames,
        String[][] mapping,
        SessionFactoryImplementor factory) {

    final String tableName = persistentClass.getTable().getQualifiedName(
            factory.getDialect(),
            factory.getSettings().getDefaultCatalogName(),
            factory.getSettings().getDefaultSchemaName()
    );

    associateSubclassNamesToSubclassTableIndex( tableName, classNames, mapping );

    Iterator itr = persistentClass.getJoinIterator();
    while ( itr.hasNext() ) {
        final Join join = (Join) itr.next();
        final String secondaryTableName = join.getTable().getQualifiedName(
                factory.getDialect(),
                factory.getSettings().getDefaultCatalogName(),
                factory.getSettings().getDefaultSchemaName()
        );
        associateSubclassNamesToSubclassTableIndex( secondaryTableName, classNames, mapping );
    }
}
项目:hibernate-ogm-ignite    文件:IgniteTestHelper.java   
@Override
public Map<String, Object> extractEntityTuple(Session session, EntityKey key) {
    SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) session.getSessionFactory();
    IgniteCache<Object, BinaryObject> cache = getEntityCache( sessionFactory, key.getMetadata() );
    Object cacheKey = getProvider( sessionFactory ).createKeyObject( key );

    Map<String, Object> result = new HashMap<>();
    BinaryObject po = cache.get( cacheKey );

    TupleSnapshot snapshot = new IgniteTupleSnapshot( cacheKey, po, key.getMetadata() );
    for ( String fieldName : snapshot.getColumnNames() ) {
        result.put( fieldName, snapshot.get( fieldName ) );
    }

    return result;
}
项目:lams    文件:BasicCollectionLoader.java   
protected BasicCollectionLoader(
        QueryableCollection collectionPersister,
        int batchSize,
        String subquery,
        SessionFactoryImplementor factory,
        LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
    super( collectionPersister, factory, loadQueryInfluencers );

    JoinWalker walker = new BasicCollectionJoinWalker(
            collectionPersister,
            batchSize,
            subquery,
            factory,
            loadQueryInfluencers
    );
    initFromWalker( walker );

    postInstantiate();

    if ( LOG.isDebugEnabled() ) {
        LOG.debugf( "Static select for collection %s: %s", collectionPersister.getRole(), getSQLString() );
    }
}
项目:lams    文件:JoinHelper.java   
public JoinDefinedByMetadata createCollectionJoin(
        QuerySpace leftHandSide,
        String lhsPropertyName,
        CollectionQuerySpace rightHandSide,
        boolean rightHandSideRequired,
        CollectionType joinedPropertyType,
        SessionFactoryImplementor sessionFactory) {
    return new JoinImpl(
            leftHandSide,
            lhsPropertyName,
            rightHandSide,
            joinedPropertyType.getAssociatedJoinable( sessionFactory ).getKeyColumnNames(),
            joinedPropertyType,
            rightHandSideRequired
    );
}
项目:lams    文件:PositionSubstringFunction.java   
@Override
public String render(Type firstArgumentType, List args, SessionFactoryImplementor factory) throws QueryException {
    final boolean threeArgs = args.size() > 2;
    final Object pattern = args.get( 0 );
    final Object string = args.get( 1 );
    final Object start = threeArgs ? args.get( 2 ) : null;

    final StringBuilder buf = new StringBuilder();
    if (threeArgs) {
        buf.append( '(' );
    }
    buf.append( "position(" ).append( pattern ).append( " in " );
    if (threeArgs) {
        buf.append( "substring(");
    }
    buf.append( string );
    if (threeArgs) {
        buf.append( ", " ).append( start ).append( ')' );
    }
    buf.append( ')' );
    if (threeArgs) {
        buf.append( '+' ).append( start ).append( "-1)" );
    }
    return buf.toString();
}
项目: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    文件:SelectLockingStrategy.java   
protected String generateLockString(int timeout) {
    final SessionFactoryImplementor factory = getLockable().getFactory();
    final LockOptions lockOptions = new LockOptions( getLockMode() );
    lockOptions.setTimeOut( timeout );
    final SimpleSelect select = new SimpleSelect( factory.getDialect() )
            .setLockOptions( lockOptions )
            .setTableName( getLockable().getRootTableName() )
            .addColumn( getLockable().getRootTableIdentifierColumnNames()[0] )
            .addCondition( getLockable().getRootTableIdentifierColumnNames(), "=?" );
    if ( getLockable().isVersioned() ) {
        select.addCondition( getLockable().getVersionColumnName(), "=?" );
    }
    if ( factory.getSettings().isCommentsEnabled() ) {
        select.setComment( getLockMode() + " lock " + getLockable().getEntityName() );
    }
    return select.toStatementString();
}
项目:lams    文件:JoinedSubclassEntityPersister.java   
private Set<String> processPersistentClassHierarchy(
        PersistentClass persistentClass,
        boolean isBase,
        SessionFactoryImplementor factory,
        String[][] mapping) {

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // collect all the class names that indicate that the "main table" of the given PersistentClass should be
    // included when one of the collected class names is used in TREAT
    final Set<String> classNames = new HashSet<String>();

    final Iterator itr = persistentClass.getDirectSubclasses();
    while ( itr.hasNext() ) {
        final Subclass subclass = (Subclass) itr.next();
        final Set<String> subclassSubclassNames = processPersistentClassHierarchy(
                subclass,
                false,
                factory,
                mapping
        );
        classNames.addAll( subclassSubclassNames );
    }

    classNames.add( persistentClass.getEntityName() );

    if ( ! isBase ) {
        MappedSuperclass msc = persistentClass.getSuperMappedSuperclass();
        while ( msc != null ) {
            classNames.add( msc.getMappedClass().getName() );
            msc = msc.getSuperMappedSuperclass();
        }

        associateSubclassNamesToSubclassTableIndexes( persistentClass, classNames, mapping, factory );
    }

    return classNames;
}
项目:lams    文件:UnionSubclassEntityPersister.java   
public UnionSubclassEntityPersister(
        final EntityBinding entityBinding,
        final EntityRegionAccessStrategy cacheAccessStrategy,
        final NaturalIdRegionAccessStrategy naturalIdRegionAccessStrategy,
        final SessionFactoryImplementor factory,
        final Mapping mapping) throws HibernateException {
    super(entityBinding, cacheAccessStrategy, naturalIdRegionAccessStrategy, factory );
    // TODO: implement!!! initializing final fields to null to make compiler happy.
    subquery = null;
    tableName = null;
    subclassClosure = null;
    spaces = null;
    subclassSpaces = null;
    discriminatorValue = null;
    discriminatorSQLValue = null;
    constraintOrderedTableNames = null;
    constraintOrderedKeyColumnNames = null;
}
项目:lams    文件:OneToManyLoadQueryDetails.java   
/**
 * Constructs a EntityLoadQueryDetails object from the given inputs.
 *
 * @param loadPlan The load plan
 * @param buildingParameters Any influencers that would affect the generated SQL (mostly we are concerned with those
 * that add additional joins here)
 * @param factory The SessionFactory
 *
 * @return The EntityLoadQueryDetails
 */
OneToManyLoadQueryDetails(
        LoadPlan loadPlan,
        AliasResolutionContextImpl aliasResolutionContext,
        CollectionReturn rootReturn,
        QueryBuildingParameters buildingParameters,
        SessionFactoryImplementor factory) {
    super(
            loadPlan,
            aliasResolutionContext,
            rootReturn,
            buildingParameters,
            factory
    );
    generate();
}
项目:ipf-flow-manager    文件:CustomEventRegistration.java   
@Override
public void integrate(Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
    EventListenerRegistry service = serviceRegistry.getService(org.hibernate.event.service.spi.EventListenerRegistry.class);

    StandardPBEStringEncryptor encrypt = new StandardPBEStringEncryptor();
    encrypt.setPassword("test_password");
    RenderedMessageEncryptEventListener encryptListener = new RenderedMessageEncryptEventListener();
    encryptListener.setStringEncryptor(encrypt);

    RenderedMessageDecryptEventListener decryptListener = new RenderedMessageDecryptEventListener();
    decryptListener.setStringEncryptor(encrypt);

    FullTextIndexEventListener fullTextListener = new FullTextIndexEventListener();

    service.appendListeners(EventType.PRE_UPDATE, encryptListener);
    service.prependListeners(EventType.POST_UPDATE, decryptListener);
    service.appendListeners(EventType.PRE_INSERT, encryptListener);
    service.prependListeners(EventType.POST_INSERT, decryptListener);
    service.appendListeners(EventType.POST_LOAD, decryptListener);
}
项目:lams    文件:SubselectOneToManyLoader.java   
public SubselectOneToManyLoader(
        QueryableCollection persister, 
        String subquery,
        Collection entityKeys,
        QueryParameters queryParameters,
        Map<String, int[]> namedParameterLocMap,
        SessionFactoryImplementor factory, 
        LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
    super( persister, 1, subquery, factory, loadQueryInfluencers );

    keys = new Serializable[ entityKeys.size() ];
    Iterator iter = entityKeys.iterator();
    int i=0;
    while ( iter.hasNext() ) {
        keys[i++] = ( (EntityKey) iter.next() ).getIdentifier();
    }

    this.namedParameters = queryParameters.getNamedParameters();
    this.types = queryParameters.getFilteredPositionalParameterTypes();
    this.values = queryParameters.getFilteredPositionalParameterValues();
    this.namedParameterLocMap = namedParameterLocMap;
}
项目:hibernate-ogm-redis    文件:RedisTestHelper.java   
private static RedisDatastoreProvider getProvider(SessionFactory sessionFactory) {
    DatastoreProvider provider = ( (SessionFactoryImplementor) sessionFactory ).getServiceRegistry().getService(
            DatastoreProvider.class
    );
    if ( !( RedisDatastoreProvider.class.isInstance( provider ) ) ) {
        throw new RuntimeException( "Not testing with RedisDatastoreProvider, cannot extract underlying map." );
    }

    return RedisDatastoreProvider.class.cast( provider );
}
项目:lams    文件:AbstractNullnessCheckNode.java   
@Override
public void initialize() {
    // TODO : this really needs to be delayed unitl after we definitively know the operand node type;
    // where this is currently a problem is parameters for which where we cannot unequivocally
    // resolve an expected type
    Type operandType = extractDataType( getOperand() );
    if ( operandType == null ) {
        return;
    }
    SessionFactoryImplementor sessionFactory = getSessionFactoryHelper().getFactory();
    int operandColumnSpan = operandType.getColumnSpan( sessionFactory );
    if ( operandColumnSpan > 1 ) {
        mutateRowValueConstructorSyntax( operandColumnSpan );
    }
}
项目:lams    文件:AbstractCompositionAttribute.java   
protected AbstractCompositionAttribute(
        AttributeSource source,
        SessionFactoryImplementor sessionFactory,
        int entityBasedAttributeNumber,
        String attributeName,
        CompositeType attributeType,
        int columnStartPosition,
        BaselineAttributeInformation baselineInfo) {
    super( source, sessionFactory, entityBasedAttributeNumber, attributeName, attributeType, baselineInfo );
    this.columnStartPosition = columnStartPosition;
}
项目:lams    文件:PersisterFactoryImpl.java   
@Override
@SuppressWarnings( {"unchecked"})
public EntityPersister createEntityPersister(
        PersistentClass metadata,
        EntityRegionAccessStrategy cacheAccessStrategy,
        NaturalIdRegionAccessStrategy naturalIdRegionAccessStrategy,
        SessionFactoryImplementor factory,
        Mapping cfg) {
    Class<? extends EntityPersister> persisterClass = metadata.getEntityPersisterClass();
    if ( persisterClass == null ) {
        persisterClass = serviceRegistry.getService( PersisterClassResolver.class ).getEntityPersisterClass( metadata );
    }
    return create( persisterClass, ENTITY_PERSISTER_CONSTRUCTOR_ARGS, metadata, cacheAccessStrategy, naturalIdRegionAccessStrategy, factory, cfg );
}
项目:hibernate-ogm-ignite    文件:IgniteQueryParserServiceInitiator.java   
@Override
public QueryParserService initiateService(
        SessionFactoryImplementor sessionFactory,
        SessionFactoryOptions sessionFactoryOptions,
        ServiceRegistryImplementor registry) {
    return IgniteQueryParserService.INSTANCE;
}
项目:lams    文件:AnyType.java   
@Override
public String toLoggableString(Object value, SessionFactoryImplementor factory) throws HibernateException {
    //TODO: terrible implementation!
    return value == null
            ? "null"
            : factory.getTypeHelper()
            .entity( HibernateProxyHelper.getClassWithoutInitializingProxy( value ) )
            .toLoggableString( value, factory );
}
项目:lams    文件:MessageHelper.java   
/**
 * Generate an info message string relating to a particular entity.
 *
 * @param persister The persister for the entity
 * @param id The entity id value
 * @param factory The session factory - Could be null!
 * @return An info string, in the form [FooBar#1]
 */
public static String infoString(
        EntityPersister persister,
        Object id, 
        SessionFactoryImplementor factory) {
    StringBuilder s = new StringBuilder();
    s.append( '[' );
    Type idType;
    if( persister == null ) {
        s.append( "<null EntityPersister>" );
        idType = null;
    }
    else {
        s.append( persister.getEntityName() );
        idType = persister.getIdentifierType();
    }
    s.append( '#' );

    if ( id == null ) {
        s.append( "<null>" );
    }
    else {
        if ( idType == null ) {
            s.append( id );
        }
        else {
            if ( factory != null ) {
                s.append( idType.toLoggableString( id, factory ) );
            }
            else {
                s.append( "<not loggable>" );
            }
        }
    }
    s.append( ']' );

    return s.toString();

}
项目:lams    文件:CollectionType.java   
@Override
public void setToXMLNode(Node node, Object value, SessionFactoryImplementor factory)
        throws HibernateException {
    if ( !isEmbeddedInXML ) {
        node.detach();
    }
    else {
        replaceNode( node, (Element) value );
    }
}
项目:lams    文件:AnyType.java   
@Override
public String getOnCondition(
        String alias,
        SessionFactoryImplementor factory,
        Map enabledFilters,
        Set<String> treatAsDeclarations) {
    throw new UnsupportedOperationException();
}
项目:lams    文件:FilterHelper.java   
/**
 * The map of defined filters.  This is expected to be in format
 * where the filter names are the map keys, and the defined
 * conditions are the values.
 *
 * @param filters The map of defined filters.
 * @param factory The session factory
 */
public FilterHelper(List<FilterConfiguration> filters, SessionFactoryImplementor factory) {
    int filterCount = filters.size();
    filterNames = new String[filterCount];
    filterConditions = new String[filterCount];
    filterAutoAliasFlags = new boolean[filterCount];
    filterAliasTableMaps = new Map[filterCount];
    filterCount = 0;
    for ( final FilterConfiguration filter : filters ) {
        filterAutoAliasFlags[filterCount] = false;
        filterNames[filterCount] = filter.getName();
        filterConditions[filterCount] = filter.getCondition();
        filterAliasTableMaps[filterCount] = filter.getAliasTableMap( factory );
        if ( (filterAliasTableMaps[filterCount].isEmpty() || isTableFromPersistentClass( filterAliasTableMaps[filterCount] )) && filter
                .useAutoAliasInjection() ) {
            filterConditions[filterCount] = Template.renderWhereStringTemplate(
                    filter.getCondition(),
                    FilterImpl.MARKER,
                    factory.getDialect(),
                    factory.getSqlFunctionRegistry()
            );
            filterAutoAliasFlags[filterCount] = true;
        }
        filterConditions[filterCount] = StringHelper.replace(
                filterConditions[filterCount],
                ":",
                ":" + filterNames[filterCount] + "."
        );
        filterCount++;
    }
}
项目:lams    文件:ByteArrayBlobType.java   
@Override
public boolean isEqual(Object x, Object y, SessionFactoryImplementor factory) {
    if ( x == y ) return true;
    if ( x == null || y == null ) return false;
    if ( x instanceof Byte[] ) {
        Object[] o1 = (Object[]) x;
        Object[] o2 = (Object[]) y;
        return ArrayHelper.isEquals( o1, o2 );
    }
    else {
        byte[] c1 = (byte[]) x;
        byte[] c2 = (byte[]) y;
        return ArrayHelper.isEquals( c1, c2 );
    }
}
项目:lams    文件:CollectionCacheInvalidator.java   
private void integrate(SessionFactoryServiceRegistry serviceRegistry, SessionFactoryImplementor sessionFactory) {
    if ( !sessionFactory.getSettings().isAutoEvictCollectionCache() ) {
        // feature is disabled
        return;
    }
    if ( !sessionFactory.getSettings().isSecondLevelCacheEnabled() ) {
        // Nothing to do, if caching is disabled
        return;
    }
    EventListenerRegistry eventListenerRegistry = serviceRegistry.getService( EventListenerRegistry.class );
    eventListenerRegistry.appendListeners( EventType.POST_INSERT, this );
    eventListenerRegistry.appendListeners( EventType.POST_DELETE, this );
    eventListenerRegistry.appendListeners( EventType.POST_UPDATE, this );
}
项目:lams    文件:PropertyFactory.java   
/**
 * Generates a VersionProperty representation for an entity mapping given its
 * version mapping Property.
 *
 * @param property The version mapping Property.
 * @param lazyAvailable Is property lazy loading currently available.
 * @return The appropriate VersionProperty definition.
 */
public static VersionProperty buildVersionProperty(
        EntityPersister persister,
        SessionFactoryImplementor sessionFactory,
        int attributeNumber,
        Property property,
        boolean lazyAvailable) {
    String mappedUnsavedValue = ( (KeyValue) property.getValue() ).getNullValue();

    VersionValue unsavedValue = UnsavedValueFactory.getUnsavedVersionValue(
            mappedUnsavedValue,
            getGetter( property ),
            (VersionType) property.getType(),
            getConstructor( property.getPersistentClass() )
    );

    boolean lazy = lazyAvailable && property.isLazy();

    return new VersionProperty(
            persister,
            sessionFactory,
            attributeNumber,
            property.getName(),
            property.getValue().getType(),
            new BaselineAttributeInformation.Builder()
                    .setLazy( lazy )
                    .setInsertable( property.isInsertable() )
                    .setUpdateable( property.isUpdateable() )
                    .setValueGenerationStrategy( property.getValueGenerationStrategy() )
                    .setNullable( property.isOptional() )
                    .setDirtyCheckable( property.isUpdateable() && !lazy )
                    .setVersionable( property.isOptimisticLocked() )
                    .setCascadeStyle( property.getCascadeStyle() )
                    .createInformation(),
            unsavedValue
        );
}
项目:lams    文件:BatchingEntityLoaderBuilder.java   
public static BatchingEntityLoaderBuilder getBuilder(SessionFactoryImplementor factory) {
        switch ( factory.getSettings().getBatchFetchStyle() ) {
            case PADDED: {
                return PaddedBatchingEntityLoaderBuilder.INSTANCE;
            }
            case DYNAMIC: {
                return DynamicBatchingEntityLoaderBuilder.INSTANCE;
            }
            default: {
                return org.hibernate.loader.entity.plan.LegacyBatchingEntityLoaderBuilder.INSTANCE;
//              return LegacyBatchingEntityLoaderBuilder.INSTANCE;
            }
        }
    }
项目:lams    文件:BatchingEntityLoaderBuilder.java   
/**
 * Builds a batch-fetch capable loader based on the given persister, lock-mode, etc.
 *
 * @param persister The entity persister
 * @param batchSize The maximum number of ids to batch-fetch at once
 * @param lockMode The lock mode
 * @param factory The SessionFactory
 * @param influencers Any influencers that should affect the built query
 *
 * @return The loader.
 */
public UniqueEntityLoader buildLoader(
        OuterJoinLoadable persister,
        int batchSize,
        LockMode lockMode,
        SessionFactoryImplementor factory,
        LoadQueryInfluencers influencers) {
    if ( batchSize <= 1 ) {
        // no batching
        return buildNonBatchingLoader( persister, lockMode, factory, influencers );
    }
    return buildBatchingLoader( persister, batchSize, lockMode, factory, influencers );
}
项目:lams    文件:ClassicQueryTranslatorFactory.java   
/**
 * @see QueryTranslatorFactory#createQueryTranslator
 */
public QueryTranslator createQueryTranslator(
        String queryIdentifier,
        String queryString,
        Map filters,
        SessionFactoryImplementor factory,
        EntityGraphQueryHint entityGraphQueryHint) {
    if (entityGraphQueryHint != null) {
        throw new QueryException( "EntityGraphs cannot be applied queries using the classic QueryTranslator!" );
    }
    return new QueryTranslatorImpl( queryIdentifier, queryString, filters, factory );
}
项目:lams    文件:Template.java   
public static String renderOrderByStringTemplate(
        String orderByFragment,
        final ColumnMapper columnMapper,
        final SessionFactoryImplementor sessionFactory,
        final Dialect dialect,
        final SQLFunctionRegistry functionRegistry) {
    return translateOrderBy(
            orderByFragment,
            columnMapper,
            sessionFactory,
            dialect,
            functionRegistry
    ).injectAliases( LEGACY_ORDER_BY_ALIAS_RESOLVER );
}
项目:lams    文件:EntityBasedAssociationAttribute.java   
public EntityBasedAssociationAttribute(
        EntityPersister source,
        SessionFactoryImplementor sessionFactory,
        int attributeNumber,
        String attributeName,
        AssociationType attributeType,
        BaselineAttributeInformation baselineInfo) {
    super( source, sessionFactory, attributeNumber, attributeName, attributeType, baselineInfo );
}
项目:hibernate-ogm-ignite    文件:IgniteTestHelper.java   
@Override
public long getNumberOfEntities(SessionFactory sessionFactory) {
    int entityCount = 0;
    Set<IgniteCache<?, ?>> processedCaches = Collections.newSetFromMap( new IdentityHashMap<IgniteCache<?, ?>, Boolean>() );
    for ( EntityPersister entityPersister : ( (SessionFactoryImplementor) sessionFactory ).getEntityPersisters().values() ) {
        IgniteCache<?, ?> entityCache = getEntityCache( sessionFactory, ( (OgmEntityPersister) entityPersister ).getEntityKeyMetadata() );
        if ( !processedCaches.contains( entityCache ) ) {
            entityCount += entityCache.size( CachePeekMode.ALL );
            processedCaches.add( entityCache );
        }
    }
    return entityCount;
}
项目:lams    文件:EntityLoader.java   
public EntityLoader(
        OuterJoinLoadable persister,
        LockOptions lockOptions,
        SessionFactoryImplementor factory,
        LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
    this( persister, 1, lockOptions, factory, loadQueryInfluencers );
}