idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
23,900 | public List < Object > loadEntitiesFromTuples ( SharedSessionContractImplementor session , LockOptions lockOptions , OgmLoadingContext ogmContext ) { return loadEntity ( null , null , session , lockOptions , ogmContext ) ; } | Load a list of entities using the information in the context |
23,901 | public final void loadCollection ( final SharedSessionContractImplementor session , final Serializable id , final Type type ) throws HibernateException { if ( log . isDebugEnabled ( ) ) { log . debug ( "loading collection: " + MessageHelper . collectionInfoString ( getCollectionPersisters ( ) [ 0 ] , id , getFactory ( ) ) ) ; } Serializable [ ] ids = new Serializable [ ] { id } ; QueryParameters qp = new QueryParameters ( new Type [ ] { type } , ids , ids ) ; doQueryAndInitializeNonLazyCollections ( session , qp , OgmLoadingContext . EMPTY_CONTEXT , true ) ; log . debug ( "done loading collection" ) ; } | Called by subclasses that initialize collections |
23,902 | private List < Object > doQueryAndInitializeNonLazyCollections ( SharedSessionContractImplementor session , QueryParameters qp , OgmLoadingContext ogmLoadingContext , boolean returnProxies ) { final PersistenceContext persistenceContext = session . getPersistenceContext ( ) ; boolean defaultReadOnlyOrig = persistenceContext . isDefaultReadOnly ( ) ; persistenceContext . beforeLoad ( ) ; List < Object > result ; try { try { result = doQuery ( session , qp , ogmLoadingContext , returnProxies ) ; } finally { persistenceContext . afterLoad ( ) ; } persistenceContext . initializeNonLazyCollections ( ) ; } finally { persistenceContext . setDefaultReadOnly ( defaultReadOnlyOrig ) ; } log . debug ( "done entity load" ) ; return result ; } | Load the entity activating the persistence context execution boundaries |
23,903 | private List < Object > doQuery ( SharedSessionContractImplementor session , QueryParameters qp , OgmLoadingContext ogmLoadingContext , boolean returnProxies ) { int entitySpan = entityPersisters . length ; final List < Object > hydratedObjects = entitySpan == 0 ? null : new ArrayList < Object > ( entitySpan * 10 ) ; final Serializable id ; boolean loadSeveralIds = loadSeveralIds ( qp ) ; boolean isCollectionLoader ; if ( loadSeveralIds ) { id = null ; isCollectionLoader = false ; } else if ( qp . getOptionalId ( ) != null ) { id = qp . getOptionalId ( ) ; isCollectionLoader = false ; } else if ( ogmLoadingContext . hasResultSet ( ) ) { id = null ; isCollectionLoader = false ; } else { id = qp . getCollectionKeys ( ) [ 0 ] ; isCollectionLoader = true ; } TupleAsMapResultSet resultset = getResultSet ( id , qp , ogmLoadingContext , session ) ; handleEmptyCollections ( qp . getCollectionKeys ( ) , resultset , session ) ; final org . hibernate . engine . spi . EntityKey [ ] keys = new org . hibernate . engine . spi . EntityKey [ entitySpan ] ; Object result = null ; List < Object > results = new ArrayList < Object > ( ) ; if ( isCollectionLoader ) { preLoadBatchFetchingQueue ( session , resultset ) ; } try { while ( resultset . next ( ) ) { result = getRowFromResultSet ( resultset , session , qp , ogmLoadingContext , id , hydratedObjects , keys , returnProxies ) ; results . add ( result ) ; } } catch ( SQLException e ) { } initializeEntitiesAndCollections ( hydratedObjects , resultset , session , qp . isReadOnly ( session ) ) ; return results ; } | Execute the physical query and initialize the various entities and collections |
23,904 | private void readCollectionElement ( final Object optionalOwner , final Serializable optionalKey , final CollectionPersister persister , final CollectionAliases descriptor , final ResultSet rs , final SharedSessionContractImplementor session ) throws HibernateException , SQLException { final PersistenceContext persistenceContext = session . getPersistenceContext ( ) ; final Serializable collectionRowKey = ( Serializable ) persister . readKey ( rs , descriptor . getSuffixedKeyAliases ( ) , session ) ; if ( collectionRowKey != null ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "found row of collection: " + MessageHelper . collectionInfoString ( persister , collectionRowKey , getFactory ( ) ) ) ; } Object owner = optionalOwner ; if ( owner == null ) { owner = persistenceContext . getCollectionOwner ( collectionRowKey , persister ) ; if ( owner == null ) { } } PersistentCollection rowCollection = persistenceContext . getLoadContexts ( ) . getCollectionLoadContext ( rs ) . getLoadingCollection ( persister , collectionRowKey ) ; if ( rowCollection != null ) { hydrateRowCollection ( persister , descriptor , rs , owner , rowCollection ) ; } } else if ( optionalKey != null ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "result set contains (possibly empty) collection: " + MessageHelper . collectionInfoString ( persister , optionalKey , getFactory ( ) ) ) ; } persistenceContext . getLoadContexts ( ) . getCollectionLoadContext ( rs ) . getLoadingCollection ( persister , optionalKey ) ; } } | Read one collection element from the current row of the JDBC result set |
23,905 | private void instanceAlreadyLoaded ( final Tuple resultset , final int i , final OgmEntityPersister persister , final org . hibernate . engine . spi . EntityKey key , final Object object , final LockMode lockMode , final SharedSessionContractImplementor session ) throws HibernateException { if ( ! persister . isInstance ( object ) ) { throw new WrongClassException ( "loaded object was of wrong class " + object . getClass ( ) , key . getIdentifier ( ) , persister . getEntityName ( ) ) ; } if ( LockMode . NONE != lockMode && upgradeLocks ( ) ) { final boolean isVersionCheckNeeded = persister . isVersioned ( ) && session . getPersistenceContext ( ) . getEntry ( object ) . getLockMode ( ) . lessThan ( lockMode ) ; if ( isVersionCheckNeeded ) { Object oldVersion = session . getPersistenceContext ( ) . getEntry ( object ) . getVersion ( ) ; persister . checkVersionAndRaiseSOSE ( key . getIdentifier ( ) , oldVersion , session , resultset ) ; session . getPersistenceContext ( ) . getEntry ( object ) . setLockMode ( lockMode ) ; } } } | The entity instance is already in the session cache |
23,906 | private Object instanceNotYetLoaded ( final Tuple resultset , final int i , final Loadable persister , final String rowIdAlias , final org . hibernate . engine . spi . EntityKey key , final LockMode lockMode , final org . hibernate . engine . spi . EntityKey optionalObjectKey , final Object optionalObject , final List hydratedObjects , final SharedSessionContractImplementor session ) throws HibernateException { final String instanceClass = getInstanceClass ( resultset , i , persister , key . getIdentifier ( ) , session ) ; final Object object ; if ( optionalObjectKey != null && key . equals ( optionalObjectKey ) ) { object = optionalObject ; } else { object = session . instantiate ( instanceClass , key . getIdentifier ( ) ) ; } LockMode acquiredLockMode = lockMode == LockMode . NONE ? LockMode . READ : lockMode ; loadFromResultSet ( resultset , i , object , instanceClass , key , rowIdAlias , acquiredLockMode , persister , session ) ; hydratedObjects . add ( object ) ; return object ; } | The entity instance is not in the session cache |
23,907 | private void registerNonExists ( final org . hibernate . engine . spi . EntityKey [ ] keys , final Loadable [ ] persisters , final SharedSessionContractImplementor session ) { final int [ ] owners = getOwners ( ) ; if ( owners != null ) { EntityType [ ] ownerAssociationTypes = getOwnerAssociationTypes ( ) ; for ( int i = 0 ; i < keys . length ; i ++ ) { int owner = owners [ i ] ; if ( owner > - 1 ) { org . hibernate . engine . spi . EntityKey ownerKey = keys [ owner ] ; if ( keys [ i ] == null && ownerKey != null ) { final PersistenceContext persistenceContext = session . getPersistenceContext ( ) ; boolean isOneToOneAssociation = ownerAssociationTypes != null && ownerAssociationTypes [ i ] != null && ownerAssociationTypes [ i ] . isOneToOne ( ) ; if ( isOneToOneAssociation ) { persistenceContext . addNullProperty ( ownerKey , ownerAssociationTypes [ i ] . getPropertyName ( ) ) ; } } } } } } | For missing objects associated by one - to - one with another object in the result set register the fact that the object is missing with the session . |
23,908 | public Rule CriteriaOnlyFindQuery ( ) { return Sequence ( ! peek ( ) . isCliQuery ( ) , JsonParameter ( JsonObject ( ) ) , peek ( ) . setOperation ( Operation . FIND ) , peek ( ) . setCriteria ( match ( ) ) ) ; } | A find query only given as criterion . Leave it to MongoDB s own parser to handle it . |
23,909 | public static Map < String , Object > introspect ( Object obj ) throws IntrospectionException , InvocationTargetException , IllegalAccessException { Map < String , Object > result = new HashMap < > ( ) ; BeanInfo info = Introspector . getBeanInfo ( obj . getClass ( ) ) ; for ( PropertyDescriptor pd : info . getPropertyDescriptors ( ) ) { Method reader = pd . getReadMethod ( ) ; String name = pd . getName ( ) ; if ( reader != null && ! "class" . equals ( name ) ) { result . put ( name , reader . invoke ( obj ) ) ; } } return result ; } | Introspect the given object . |
23,910 | public static boolean propertyExists ( Class < ? > clazz , String property , ElementType elementType ) { if ( ElementType . FIELD . equals ( elementType ) ) { return getDeclaredField ( clazz , property ) != null ; } else { String capitalizedPropertyName = capitalize ( property ) ; Method method = getMethod ( clazz , PROPERTY_ACCESSOR_PREFIX_GET + capitalizedPropertyName ) ; if ( method != null && method . getReturnType ( ) != void . class ) { return true ; } method = getMethod ( clazz , PROPERTY_ACCESSOR_PREFIX_IS + capitalizedPropertyName ) ; if ( method != null && method . getReturnType ( ) == boolean . class ) { return true ; } } return false ; } | Whether the specified JavaBeans property exists on the given type or not . |
23,911 | public static void setField ( Object object , String field , Object value ) throws NoSuchMethodException , InvocationTargetException , IllegalAccessException { Class < ? > clazz = object . getClass ( ) ; Method m = clazz . getMethod ( PROPERTY_ACCESSOR_PREFIX_SET + capitalize ( field ) , value . getClass ( ) ) ; m . invoke ( object , value ) ; } | Set value for given object field . |
23,912 | public boolean isEmbeddedProperty ( String targetTypeName , List < String > namesWithoutAlias ) { OgmEntityPersister persister = getPersister ( targetTypeName ) ; Type propertyType = persister . getPropertyType ( namesWithoutAlias . get ( 0 ) ) ; if ( propertyType . isComponentType ( ) ) { return true ; } else if ( propertyType . isAssociationType ( ) ) { Joinable associatedJoinable = ( ( AssociationType ) propertyType ) . getAssociatedJoinable ( persister . getFactory ( ) ) ; if ( associatedJoinable . isCollection ( ) ) { OgmCollectionPersister collectionPersister = ( OgmCollectionPersister ) associatedJoinable ; return collectionPersister . getType ( ) . isComponentType ( ) ; } } return false ; } | Checks if the path leads to an embedded property or association . |
23,913 | public boolean isAssociation ( String targetTypeName , List < String > pathWithoutAlias ) { OgmEntityPersister persister = getPersister ( targetTypeName ) ; Type propertyType = persister . getPropertyType ( pathWithoutAlias . get ( 0 ) ) ; return propertyType . isAssociationType ( ) ; } | Check if the path to the property correspond to an association . |
23,914 | public List < String > findAssociationPath ( String targetTypeName , List < String > pathWithoutAlias ) { List < String > subPath = new ArrayList < String > ( pathWithoutAlias . size ( ) ) ; for ( String name : pathWithoutAlias ) { subPath . add ( name ) ; if ( isAssociation ( targetTypeName , subPath ) ) { return subPath ; } } return null ; } | Find the path to the first association in the property path . |
23,915 | private static < R > RowKey buildRowKey ( AssociationKey associationKey , R row , AssociationRowAccessor < R > accessor ) { String [ ] columnNames = associationKey . getMetadata ( ) . getRowKeyColumnNames ( ) ; Object [ ] columnValues = new Object [ columnNames . length ] ; for ( int i = 0 ; i < columnNames . length ; i ++ ) { String columnName = columnNames [ i ] ; columnValues [ i ] = associationKey . getMetadata ( ) . isKeyColumn ( columnName ) ? associationKey . getColumnValue ( columnName ) : accessor . get ( row , columnName ) ; } return new RowKey ( columnNames , columnValues ) ; } | Creates the row key of the given association row ; columns present in the given association key will be obtained from there all other columns from the given native association row . |
23,916 | protected EntityKey getEntityKey ( Tuple tuple , AssociatedEntityKeyMetadata associatedEntityKeyMetadata ) { Object [ ] columnValues = new Object [ associatedEntityKeyMetadata . getAssociationKeyColumns ( ) . length ] ; int i = 0 ; for ( String associationKeyColumn : associatedEntityKeyMetadata . getAssociationKeyColumns ( ) ) { columnValues [ i ] = tuple . get ( associationKeyColumn ) ; i ++ ; } return new EntityKey ( associatedEntityKeyMetadata . getEntityKeyMetadata ( ) , columnValues ) ; } | Returns the key of the entity targeted by the represented association retrieved from the given tuple . |
23,917 | public static boolean isPartOfRegularEmbedded ( String [ ] keyColumnNames , String column ) { return isPartOfEmbedded ( column ) && ! ArrayHelper . contains ( keyColumnNames , column ) ; } | A regular embedded is an element that it is embedded but it is not a key or a collection . |
23,918 | public String getOuterMostNullEmbeddableIfAny ( String column ) { String [ ] path = column . split ( "\\." ) ; if ( ! isEmbeddableColumn ( path ) ) { return null ; } if ( columnToOuterMostNullEmbeddableCache . containsKey ( column ) ) { return columnToOuterMostNullEmbeddableCache . get ( column ) ; } return determineAndCacheOuterMostNullEmbeddable ( column , path ) ; } | Should only called on a column that is being set to null . |
23,919 | private String determineAndCacheOuterMostNullEmbeddable ( String column , String [ ] path ) { String embeddable = path [ 0 ] ; for ( int index = 0 ; index < path . length - 1 ; index ++ ) { Set < String > columnsOfEmbeddable = getColumnsOfEmbeddableAndComputeEmbeddableNullness ( embeddable ) ; if ( nullEmbeddables . contains ( embeddable ) ) { for ( String columnOfEmbeddable : columnsOfEmbeddable ) { columnToOuterMostNullEmbeddableCache . put ( columnOfEmbeddable , embeddable ) ; } break ; } else { maybeCacheOnNonNullEmbeddable ( path , index , columnsOfEmbeddable ) ; } embeddable += "." + path [ index + 1 ] ; } return columnToOuterMostNullEmbeddableCache . get ( column ) ; } | Walks from the most outer embeddable to the most inner one look for all columns contained in these embeddables and exclude the embeddables that have a non null column because of caching the algorithm is only run once per column parameter |
23,920 | public void addNavigationalInformationForInverseSide ( ) { if ( log . isTraceEnabled ( ) ) { log . trace ( "Adding inverse navigational information for entity: " + MessageHelper . infoString ( persister , id , persister . getFactory ( ) ) ) ; } for ( int propertyIndex = 0 ; propertyIndex < persister . getEntityMetamodel ( ) . getPropertySpan ( ) ; propertyIndex ++ ) { if ( persister . isPropertyOfTable ( propertyIndex , tableIndex ) ) { AssociationKeyMetadata associationKeyMetadata = getInverseAssociationKeyMetadata ( propertyIndex ) ; if ( associationKeyMetadata == null ) { continue ; } Object [ ] newColumnValues = LogicalPhysicalConverterHelper . getColumnValuesFromResultset ( resultset , persister . getPropertyColumnNames ( propertyIndex ) ) ; if ( ! CollectionHelper . isEmptyOrContainsOnlyNull ( ( newColumnValues ) ) ) { addNavigationalInformationForInverseSide ( propertyIndex , associationKeyMetadata , newColumnValues ) ; } } } } | Updates all inverse associations managed by a given entity . |
23,921 | public static String escapeDoubleQuotesForJson ( String text ) { if ( text == null ) { return null ; } StringBuilder builder = new StringBuilder ( text . length ( ) ) ; for ( int i = 0 ; i < text . length ( ) ; i ++ ) { char c = text . charAt ( i ) ; switch ( c ) { case '"' : case '\\' : builder . append ( "\\" ) ; default : builder . append ( c ) ; } } return builder . toString ( ) ; } | If a text contains double quotes escape them . |
23,922 | private static Row row ( List < StatementResult > results ) { Row row = results . get ( 0 ) . getData ( ) . get ( 0 ) ; return row ; } | When we execute a single statement we only need the corresponding Row with the result . |
23,923 | static < T extends GridDialect > T getDialectFacetOrNull ( GridDialect gridDialect , Class < T > facetType ) { if ( hasFacet ( gridDialect , facetType ) ) { @ SuppressWarnings ( "unchecked" ) T asFacet = ( T ) gridDialect ; return asFacet ; } return null ; } | Returns the given dialect narrowed down to the given dialect facet in case it is implemented by the dialect . |
23,924 | public static boolean hasFacet ( GridDialect gridDialect , Class < ? extends GridDialect > facetType ) { if ( gridDialect instanceof ForwardingGridDialect ) { return hasFacet ( ( ( ForwardingGridDialect < ? > ) gridDialect ) . getGridDialect ( ) , facetType ) ; } else { return facetType . isAssignableFrom ( gridDialect . getClass ( ) ) ; } } | Whether the given grid dialect implements the specified facet or not . |
23,925 | public void initializePersistenceStrategy ( CacheMappingType cacheMappingType , Set < EntityKeyMetadata > entityTypes , Set < AssociationKeyMetadata > associationTypes , Set < IdSourceKeyMetadata > idSourceTypes , Iterable < Namespace > namespaces ) { persistenceStrategy = PersistenceStrategy . getInstance ( cacheMappingType , externalCacheManager , config . getConfigurationUrl ( ) , jtaPlatform , entityTypes , associationTypes , idSourceTypes ) ; boolean requiresCounter = hasIdGeneration ( idSourceTypes ) ; if ( requiresCounter ) { this . tableClusterHandler = new TableClusteredCounterHandler ( persistenceStrategy . getCacheManager ( ) . getCacheManager ( ) ) ; } for ( Namespace namespace : namespaces ) { for ( Sequence seq : namespace . getSequences ( ) ) { this . sequenceCounterHandlers . put ( seq . getExportIdentifier ( ) , new SequenceClusteredCounterHandler ( persistenceStrategy . getCacheManager ( ) . getCacheManager ( ) , seq ) ) ; } } this . externalCacheManager = null ; this . jtaPlatform = null ; } | Initializes the persistence strategy to be used when accessing the datastore . In particular all the required caches will be configured and initialized . |
23,926 | private static Document getProjection ( List < String > fieldNames ) { Document projection = new Document ( ) ; for ( String column : fieldNames ) { projection . put ( column , 1 ) ; } return projection ; } | Returns a projection object for specifying the fields to retrieve during a specific find operation . |
23,927 | private static Document objectForInsert ( Tuple tuple , Document dbObject ) { MongoDBTupleSnapshot snapshot = ( MongoDBTupleSnapshot ) tuple . getSnapshot ( ) ; for ( TupleOperation operation : tuple . getOperations ( ) ) { String column = operation . getColumn ( ) ; if ( notInIdField ( snapshot , column ) ) { switch ( operation . getType ( ) ) { case PUT : MongoHelpers . setValue ( dbObject , column , operation . getValue ( ) ) ; break ; case PUT_NULL : case REMOVE : MongoHelpers . resetValue ( dbObject , column ) ; break ; } } } return dbObject ; } | Creates a Document that can be passed to the MongoDB batch insert function |
23,928 | private static ClosableIterator < Tuple > doDistinct ( final MongoDBQueryDescriptor queryDescriptor , final MongoCollection < Document > collection ) { DistinctIterable < ? > distinctFieldValues = collection . distinct ( queryDescriptor . getDistinctFieldName ( ) , queryDescriptor . getCriteria ( ) , String . class ) ; Collation collation = getCollation ( queryDescriptor . getOptions ( ) ) ; distinctFieldValues = collation != null ? distinctFieldValues . collation ( collation ) : distinctFieldValues ; MongoCursor < ? > cursor = distinctFieldValues . iterator ( ) ; List < Object > documents = new ArrayList < > ( ) ; while ( cursor . hasNext ( ) ) { documents . add ( cursor . next ( ) ) ; } MapTupleSnapshot snapshot = new MapTupleSnapshot ( Collections . < String , Object > singletonMap ( "n" , documents ) ) ; return CollectionHelper . newClosableIterator ( Collections . singletonList ( new Tuple ( snapshot , SnapshotType . UNKNOWN ) ) ) ; } | do Distinct operation |
23,929 | @ SuppressWarnings ( "deprecation" ) private static WriteConcern mergeWriteConcern ( WriteConcern original , WriteConcern writeConcern ) { if ( original == null ) { return writeConcern ; } else if ( writeConcern == null ) { return original ; } else if ( original . equals ( writeConcern ) ) { return original ; } Object wObject ; int wTimeoutMS ; boolean fsync ; Boolean journal ; if ( original . getWObject ( ) instanceof String ) { wObject = original . getWString ( ) ; } else if ( writeConcern . getWObject ( ) instanceof String ) { wObject = writeConcern . getWString ( ) ; } else { wObject = Math . max ( original . getW ( ) , writeConcern . getW ( ) ) ; } wTimeoutMS = Math . min ( original . getWtimeout ( ) , writeConcern . getWtimeout ( ) ) ; fsync = original . getFsync ( ) || writeConcern . getFsync ( ) ; if ( original . getJournal ( ) == null ) { journal = writeConcern . getJournal ( ) ; } else if ( writeConcern . getJournal ( ) == null ) { journal = original . getJournal ( ) ; } else { journal = original . getJournal ( ) || writeConcern . getJournal ( ) ; } if ( wObject instanceof String ) { return new WriteConcern ( ( String ) wObject , wTimeoutMS , fsync , journal ) ; } else { return new WriteConcern ( ( int ) wObject , wTimeoutMS , fsync , journal ) ; } } | As we merge several operations into one operation we need to be sure the write concern applied to the aggregated operation respects all the requirements expressed for each separate operation . |
23,930 | public ClosableIterator < Tuple > callStoredProcedure ( String storedProcedureName , ProcedureQueryParameters params , TupleContext tupleContext ) { validate ( params ) ; StringBuilder commandLine = createCallStoreProcedureCommand ( storedProcedureName , params ) ; Document result = callStoredProcedure ( commandLine ) ; Object resultValue = result . get ( "retval" ) ; List < Tuple > resultTuples = extractTuples ( storedProcedureName , resultValue ) ; return CollectionHelper . newClosableIterator ( resultTuples ) ; } | In MongoDB the equivalent of a stored procedure is a stored Javascript . |
23,931 | public UniqueEntityLoader buildLoader ( OuterJoinLoadable persister , int batchSize , LockMode lockMode , SessionFactoryImplementor factory , LoadQueryInfluencers influencers , BatchableEntityLoaderBuilder innerEntityLoaderBuilder ) { if ( batchSize <= 1 ) { return buildNonBatchingLoader ( persister , lockMode , factory , influencers , innerEntityLoaderBuilder ) ; } return buildBatchingLoader ( persister , batchSize , lockMode , factory , influencers , innerEntityLoaderBuilder ) ; } | Builds a batch - fetch capable loader based on the given persister lock - mode etc . |
23,932 | public UniqueEntityLoader buildLoader ( OuterJoinLoadable persister , int batchSize , LockOptions lockOptions , SessionFactoryImplementor factory , LoadQueryInfluencers influencers , BatchableEntityLoaderBuilder innerEntityLoaderBuilder ) { if ( batchSize <= 1 ) { return buildNonBatchingLoader ( persister , lockOptions , factory , influencers , innerEntityLoaderBuilder ) ; } return buildBatchingLoader ( persister , batchSize , lockOptions , factory , influencers , innerEntityLoaderBuilder ) ; } | Builds a batch - fetch capable loader based on the given persister lock - options etc . |
23,933 | private void applyProperties ( AssociationKey associationKey , Tuple associationRow , Relationship relationship ) { String [ ] indexColumns = associationKey . getMetadata ( ) . getRowKeyIndexColumnNames ( ) ; for ( int i = 0 ; i < indexColumns . length ; i ++ ) { String propertyName = indexColumns [ i ] ; Object propertyValue = associationRow . get ( propertyName ) ; relationship . setProperty ( propertyName , propertyValue ) ; } } | The only properties added to a relationship are the columns representing the index of the association . |
23,934 | public Association getAssociation ( String collectionRole ) { if ( associations == null ) { return null ; } return associations . get ( collectionRole ) ; } | Return the association as cached in the entry state . |
23,935 | public void setAssociation ( String collectionRole , Association association ) { if ( associations == null ) { associations = new HashMap < > ( ) ; } associations . put ( collectionRole , association ) ; } | Set the association in the entry state . |
23,936 | public void addExtraState ( EntityEntryExtraState extraState ) { if ( next == null ) { next = extraState ; } else { next . addExtraState ( extraState ) ; } } | state chain management ops below |
23,937 | protected StrongCounter getCounterOrCreateIt ( String counterName , int initialValue ) { CounterManager counterManager = EmbeddedCounterManagerFactory . asCounterManager ( cacheManager ) ; if ( ! counterManager . isDefined ( counterName ) ) { LOG . tracef ( "Counter %s is not defined, creating it" , counterName ) ; validateGlobalConfiguration ( ) ; counterManager . defineCounter ( counterName , CounterConfiguration . builder ( CounterType . UNBOUNDED_STRONG ) . initialValue ( initialValue ) . storage ( Storage . PERSISTENT ) . build ( ) ) ; } StrongCounter strongCounter = counterManager . getStrongCounter ( counterName ) ; return strongCounter ; } | Create a counter if one is not defined already otherwise return the existing one . |
23,938 | public Set < TupleOperation > getOperations ( ) { if ( currentState == null ) { return Collections . emptySet ( ) ; } else { return new SetFromCollection < TupleOperation > ( currentState . values ( ) ) ; } } | Return the list of actions on the tuple . Inherently deduplicated operations |
23,939 | private < A extends Annotation > AnnotationConverter < A > getConverter ( Annotation annotation ) { MappingOption mappingOption = annotation . annotationType ( ) . getAnnotation ( MappingOption . class ) ; if ( mappingOption == null ) { return null ; } @ SuppressWarnings ( "unchecked" ) Class < ? extends AnnotationConverter < A > > converterClass = ( Class < ? extends AnnotationConverter < A > > ) mappingOption . value ( ) ; try { return converterClass . newInstance ( ) ; } catch ( Exception e ) { throw log . cannotConvertAnnotation ( converterClass , e ) ; } } | Returns a converter instance for the given annotation . |
23,940 | public static String [ ] slice ( String [ ] strings , int begin , int length ) { String [ ] result = new String [ length ] ; System . arraycopy ( strings , begin , result , 0 , length ) ; return result ; } | Create a smaller array from an existing one . |
23,941 | public static < T > int indexOf ( T [ ] array , T element ) { for ( int i = 0 ; i < array . length ; i ++ ) { if ( array [ i ] . equals ( element ) ) { return i ; } } return - 1 ; } | Return the position of an element inside an array |
23,942 | public static < T > T [ ] concat ( T [ ] first , T ... second ) { int firstLength = first . length ; int secondLength = second . length ; @ SuppressWarnings ( "unchecked" ) T [ ] result = ( T [ ] ) Array . newInstance ( first . getClass ( ) . getComponentType ( ) , firstLength + secondLength ) ; System . arraycopy ( first , 0 , result , 0 , firstLength ) ; System . arraycopy ( second , 0 , result , firstLength , secondLength ) ; return result ; } | Concats two arrays . |
23,943 | public static < T > T [ ] concat ( T firstElement , T ... array ) { @ SuppressWarnings ( "unchecked" ) T [ ] result = ( T [ ] ) Array . newInstance ( firstElement . getClass ( ) , 1 + array . length ) ; result [ 0 ] = firstElement ; System . arraycopy ( array , 0 , result , 1 , array . length ) ; return result ; } | Concats an element and an array . |
23,944 | private Serializable doWorkInIsolationTransaction ( final SharedSessionContractImplementor session ) throws HibernateException { class Work extends AbstractReturningWork < IntegralDataTypeHolder > { private final SharedSessionContractImplementor localSession = session ; public IntegralDataTypeHolder execute ( Connection connection ) throws SQLException { try { return doWorkInCurrentTransactionIfAny ( localSession ) ; } catch ( RuntimeException sqle ) { throw new HibernateException ( "Could not get or update next value" , sqle ) ; } } } boolean workInTransaction = false ; Work work = new Work ( ) ; Serializable generatedValue = session . getTransactionCoordinator ( ) . createIsolationDelegate ( ) . delegateWork ( work , workInTransaction ) ; return generatedValue ; } | copied and altered from TransactionHelper |
23,945 | public static void registerOgmExternalizers ( SerializationConfigurationBuilder cfg ) { for ( AdvancedExternalizer < ? > advancedExternalizer : ogmExternalizers . values ( ) ) { cfg . addAdvancedExternalizer ( advancedExternalizer ) ; } } | Registers all custom Externalizer implementations that Hibernate OGM needs into an Infinispan CacheManager configuration . |
23,946 | public static void registerOgmExternalizers ( GlobalConfiguration globalCfg ) { Map < Integer , AdvancedExternalizer < ? > > externalizerMap = globalCfg . serialization ( ) . advancedExternalizers ( ) ; externalizerMap . putAll ( ogmExternalizers ) ; } | Registers all custom Externalizer implementations that Hibernate OGM needs into a running Infinispan CacheManager configuration . This is only safe to do when Caches from this CacheManager haven t been started yet or the ones already started do not contain any data needing these . |
23,947 | public static void validateExternalizersPresent ( EmbeddedCacheManager externalCacheManager ) { Map < Integer , AdvancedExternalizer < ? > > externalizerMap = externalCacheManager . getCacheManagerConfiguration ( ) . serialization ( ) . advancedExternalizers ( ) ; for ( AdvancedExternalizer < ? > ogmExternalizer : ogmExternalizers . values ( ) ) { final Integer externalizerId = ogmExternalizer . getId ( ) ; AdvancedExternalizer < ? > registeredExternalizer = externalizerMap . get ( externalizerId ) ; if ( registeredExternalizer == null ) { throw log . externalizersNotRegistered ( externalizerId , ogmExternalizer . getClass ( ) ) ; } else if ( ! registeredExternalizer . getClass ( ) . equals ( ogmExternalizer ) ) { if ( registeredExternalizer . getClass ( ) . toString ( ) . equals ( ogmExternalizer . getClass ( ) . toString ( ) ) ) { throw log . registeredExternalizerNotLoadedFromOGMClassloader ( registeredExternalizer . getClass ( ) ) ; } else { throw log . externalizerIdNotMatchingType ( externalizerId , registeredExternalizer , ogmExternalizer ) ; } } } } | Verify that all OGM custom externalizers are present . N . B . even if some Externalizer is only needed in specific configuration it is not safe to start a CacheManager without one as the same CacheManager might be used or have been used in the past to store data using a different configuration . |
23,948 | public void writeLock ( EntityKey key , int timeout ) { ReadWriteLock lock = getLock ( key ) ; Lock writeLock = lock . writeLock ( ) ; acquireLock ( key , timeout , writeLock ) ; } | Acquires a write lock on a specific key . |
23,949 | public void readLock ( EntityKey key , int timeout ) { ReadWriteLock lock = getLock ( key ) ; Lock readLock = lock . readLock ( ) ; acquireLock ( key , timeout , readLock ) ; } | Acquires a read lock on a specific key . |
23,950 | public Map < AssociationKey , Map < RowKey , Map < String , Object > > > getAssociationsMap ( ) { return Collections . unmodifiableMap ( associationsKeyValueStorage ) ; } | Meant to execute assertions in tests only |
23,951 | public static String flatten ( String left , String right ) { return left == null || left . isEmpty ( ) ? right : left + "." + right ; } | Links the two field names into a single left . right field name . If the left field is empty right is returned |
23,952 | public static boolean organizeAssociationMapByRowKey ( org . hibernate . ogm . model . spi . Association association , AssociationKey key , AssociationContext associationContext ) { if ( association . isEmpty ( ) ) { return false ; } if ( key . getMetadata ( ) . getRowKeyIndexColumnNames ( ) . length != 1 ) { return false ; } Object valueOfFirstRow = association . get ( association . getKeys ( ) . iterator ( ) . next ( ) ) . get ( key . getMetadata ( ) . getRowKeyIndexColumnNames ( ) [ 0 ] ) ; if ( ! ( valueOfFirstRow instanceof String ) ) { return false ; } return getMapStorage ( associationContext ) == MapStorageType . BY_KEY ; } | Whether the rows of the given association should be stored in a hash using the single row key column as key or not . |
23,953 | private void scheduleBatchLoadIfNeeded ( Serializable id , SharedSessionContractImplementor session ) throws MappingException { if ( StringHelper . isEmpty ( delegate . getRHSUniqueKeyPropertyName ( ) ) && id != null ) { EntityPersister persister = session . getFactory ( ) . getMetamodel ( ) . entityPersister ( delegate . getAssociatedEntityName ( ) ) ; EntityKey entityKey = session . generateEntityKey ( id , persister ) ; if ( ! session . getPersistenceContext ( ) . containsEntity ( entityKey ) ) { session . getPersistenceContext ( ) . getBatchFetchQueue ( ) . addBatchLoadableEntityKey ( entityKey ) ; } } } | Register the entity as batch loadable if enabled |
23,954 | public GeoMultiPoint addPoint ( GeoPoint point ) { Contracts . assertNotNull ( point , "point" ) ; this . points . add ( point ) ; return this ; } | Adds a new point . |
23,955 | public String findAlias ( String entityAlias , List < String > propertyPathWithoutAlias ) { RelationshipAliasTree aliasTree = relationshipAliases . get ( entityAlias ) ; if ( aliasTree == null ) { return null ; } RelationshipAliasTree associationAlias = aliasTree ; for ( int i = 0 ; i < propertyPathWithoutAlias . size ( ) ; i ++ ) { associationAlias = associationAlias . findChild ( propertyPathWithoutAlias . get ( i ) ) ; if ( associationAlias == null ) { return null ; } } return associationAlias . getAlias ( ) ; } | Given the alias of the entity and the path to the relationship it will return the alias of the component . |
23,956 | public Node createEmbedded ( GraphDatabaseService executionEngine , Object [ ] columnValues ) { Map < String , Object > params = params ( columnValues ) ; Result result = executionEngine . execute ( getCreateEmbeddedNodeQuery ( ) , params ) ; return singleResult ( result ) ; } | Create a single node representing an embedded element . |
23,957 | public Node findEntity ( GraphDatabaseService executionEngine , Object [ ] columnValues ) { Map < String , Object > params = params ( columnValues ) ; Result result = executionEngine . execute ( getFindEntityQuery ( ) , params ) ; return singleResult ( result ) ; } | Find the node corresponding to an entity . |
23,958 | public Node insertEntity ( GraphDatabaseService executionEngine , Object [ ] columnValues ) { Map < String , Object > params = params ( columnValues ) ; Result result = executionEngine . execute ( getCreateEntityQuery ( ) , params ) ; return singleResult ( result ) ; } | Creates the node corresponding to an entity . |
23,959 | public ResourceIterator < Node > findEntities ( GraphDatabaseService executionEngine ) { Result result = executionEngine . execute ( getFindEntitiesQuery ( ) ) ; return result . columnAs ( BaseNeo4jEntityQueries . ENTITY_ALIAS ) ; } | Find all the node representing the entity . |
23,960 | public void removeEntity ( GraphDatabaseService executionEngine , Object [ ] columnValues ) { Map < String , Object > params = params ( columnValues ) ; executionEngine . execute ( getRemoveEntityQuery ( ) , params ) ; } | Remove the nodes representing the entity and the embedded elements attached to it . |
23,961 | public void updateEmbeddedColumn ( GraphDatabaseService executionEngine , Object [ ] keyValues , String embeddedColumn , Object value ) { String query = getUpdateEmbeddedColumnQuery ( keyValues , embeddedColumn ) ; Map < String , Object > params = params ( ArrayHelper . concat ( keyValues , value , value ) ) ; executionEngine . execute ( query , params ) ; } | Update the value of an embedded node property . |
23,962 | private static IndexOptions prepareOptions ( MongoDBIndexType indexType , Document options , String indexName , boolean unique ) { IndexOptions indexOptions = new IndexOptions ( ) ; indexOptions . name ( indexName ) . unique ( unique ) . background ( options . getBoolean ( "background" , false ) ) ; if ( unique ) { indexOptions . sparse ( ! options . containsKey ( "partialFilterExpression" ) ) ; } else if ( options . containsKey ( "partialFilterExpression" ) ) { indexOptions . partialFilterExpression ( ( Bson ) options . get ( "partialFilterExpression" ) ) ; } if ( options . containsKey ( "expireAfterSeconds" ) ) { indexOptions . expireAfter ( options . getInteger ( "expireAfterSeconds" ) . longValue ( ) , TimeUnit . SECONDS ) ; } if ( MongoDBIndexType . TEXT . equals ( indexType ) ) { if ( options . containsKey ( "default_language" ) ) { indexOptions . defaultLanguage ( options . getString ( "default_language" ) ) ; } if ( options . containsKey ( "weights" ) ) { indexOptions . weights ( ( Bson ) options . get ( "weights" ) ) ; } options . remove ( "text" ) ; } return indexOptions ; } | Prepare the options by adding additional information to them . |
23,963 | public static AssociationKeyMetadata getInverseAssociationKeyMetadata ( OgmEntityPersister mainSidePersister , int propertyIndex ) { Type propertyType = mainSidePersister . getPropertyTypes ( ) [ propertyIndex ] ; SessionFactoryImplementor factory = mainSidePersister . getFactory ( ) ; if ( ! propertyType . isAssociationType ( ) ) { return null ; } Joinable mainSideJoinable = ( ( AssociationType ) propertyType ) . getAssociatedJoinable ( factory ) ; OgmEntityPersister inverseSidePersister = null ; if ( mainSideJoinable . isCollection ( ) ) { inverseSidePersister = ( OgmEntityPersister ) ( ( OgmCollectionPersister ) mainSideJoinable ) . getElementPersister ( ) ; } else { inverseSidePersister = ( OgmEntityPersister ) mainSideJoinable ; mainSideJoinable = mainSidePersister ; } String mainSideProperty = mainSidePersister . getPropertyNames ( ) [ propertyIndex ] ; AssociationKeyMetadata inverseOneToOneMetadata = mainSidePersister . getInverseOneToOneAssociationKeyMetadata ( mainSideProperty ) ; if ( inverseOneToOneMetadata != null ) { return inverseOneToOneMetadata ; } for ( String candidateProperty : inverseSidePersister . getPropertyNames ( ) ) { Type type = inverseSidePersister . getPropertyType ( candidateProperty ) ; if ( type . isCollectionType ( ) ) { OgmCollectionPersister inverseCollectionPersister = getPersister ( factory , ( CollectionType ) type ) ; String mappedByProperty = inverseCollectionPersister . getMappedByProperty ( ) ; if ( mainSideProperty . equals ( mappedByProperty ) ) { if ( isCollectionMatching ( mainSideJoinable , inverseCollectionPersister ) ) { return inverseCollectionPersister . getAssociationKeyMetadata ( ) ; } } } } return null ; } | Returns the meta - data for the inverse side of the association represented by the given property on the given persister in case it represents the main side of a bi - directional one - to - many or many - to - many association . |
23,964 | public static OgmCollectionPersister getInverseCollectionPersister ( OgmCollectionPersister mainSidePersister ) { if ( mainSidePersister . isInverse ( ) || ! mainSidePersister . isManyToMany ( ) || ! mainSidePersister . getElementType ( ) . isEntityType ( ) ) { return null ; } EntityPersister inverseSidePersister = mainSidePersister . getElementPersister ( ) ; for ( Type type : inverseSidePersister . getPropertyTypes ( ) ) { if ( type . isCollectionType ( ) ) { OgmCollectionPersister inverseCollectionPersister = getPersister ( mainSidePersister . getFactory ( ) , ( CollectionType ) type ) ; if ( isCollectionMatching ( mainSidePersister , inverseCollectionPersister ) ) { return inverseCollectionPersister ; } } } return null ; } | Returns the given collection persister for the inverse side in case the given persister represents the main side of a bi - directional many - to - many association . |
23,965 | private static boolean isCollectionMatching ( Joinable mainSideJoinable , OgmCollectionPersister inverseSidePersister ) { boolean isSameTable = mainSideJoinable . getTableName ( ) . equals ( inverseSidePersister . getTableName ( ) ) ; if ( ! isSameTable ) { return false ; } return Arrays . equals ( mainSideJoinable . getKeyColumnNames ( ) , inverseSidePersister . getElementColumnNames ( ) ) ; } | Checks whether table name and key column names of the given joinable and inverse collection persister match . |
23,966 | public static void resetValue ( Document entity , String column ) { if ( ! column . contains ( "." ) ) { entity . remove ( column ) ; } else { String [ ] path = DOT_SEPARATOR_PATTERN . split ( column ) ; Object field = entity ; int size = path . length ; for ( int index = 0 ; index < size ; index ++ ) { String node = path [ index ] ; Document parent = ( Document ) field ; field = parent . get ( node ) ; if ( field == null && index < size - 1 ) { return ; } if ( index == size - 1 ) { parent . remove ( node ) ; } } } } | Remove a column from the Document |
23,967 | private static void validateAsMongoDBCollectionName ( String collectionName ) { Contracts . assertStringParameterNotEmpty ( collectionName , "requestedName" ) ; if ( collectionName . startsWith ( "system." ) ) { throw log . collectionNameHasInvalidSystemPrefix ( collectionName ) ; } else if ( collectionName . contains ( "\u0000" ) ) { throw log . collectionNameContainsNULCharacter ( collectionName ) ; } else if ( collectionName . contains ( "$" ) ) { throw log . collectionNameContainsDollarCharacter ( collectionName ) ; } } | Validates a String to be a valid name to be used in MongoDB for a collection name . |
23,968 | private void validateAsMongoDBFieldName ( String fieldName ) { if ( fieldName . startsWith ( "$" ) ) { throw log . fieldNameHasInvalidDollarPrefix ( fieldName ) ; } else if ( fieldName . contains ( "\u0000" ) ) { throw log . fieldNameContainsNULCharacter ( fieldName ) ; } } | Validates a String to be a valid name to be used in MongoDB for a field name . |
23,969 | private static int determineBatchSize ( boolean canGridDialectDoMultiget , int classBatchSize , int configuredDefaultBatchSize ) { if ( ! canGridDialectDoMultiget ) { return - 1 ; } else if ( classBatchSize != - 1 ) { return classBatchSize ; } else if ( configuredDefaultBatchSize != - 1 ) { return configuredDefaultBatchSize ; } else { return DEFAULT_MULTIGET_BATCH_SIZE ; } } | Returns the effective batch size . If the dialect is multiget capable and a batch size has been configured use that one otherwise the default . |
23,970 | private String getInverseOneToOneProperty ( String property , OgmEntityPersister otherSidePersister ) { for ( String candidate : otherSidePersister . getPropertyNames ( ) ) { Type candidateType = otherSidePersister . getPropertyType ( candidate ) ; if ( candidateType . isEntityType ( ) && ( ( ( EntityType ) candidateType ) . isOneToOne ( ) && isOneToOneMatching ( this , property , ( OneToOneType ) candidateType ) ) ) { return candidate ; } } return null ; } | Returns the name from the inverse side if the given property de - notes a one - to - one association . |
23,971 | public Object [ ] getDatabaseSnapshot ( Serializable id , SharedSessionContractImplementor session ) throws HibernateException { if ( log . isTraceEnabled ( ) ) { log . trace ( "Getting current persistent state for: " + MessageHelper . infoString ( this , id , getFactory ( ) ) ) ; } final Tuple resultset = getFreshTuple ( EntityKeyBuilder . fromPersister ( this , id , session ) , session ) ; if ( resultset == null || resultset . getSnapshot ( ) . isEmpty ( ) ) { return null ; } GridType [ ] types = gridPropertyTypes ; Object [ ] values = new Object [ types . length ] ; boolean [ ] includeProperty = getPropertyUpdateability ( ) ; for ( int i = 0 ; i < types . length ; i ++ ) { if ( includeProperty [ i ] ) { values [ i ] = types [ i ] . hydrate ( resultset , getPropertyAliases ( "" , i ) , session , null ) ; } } return values ; } | This snapshot is meant to be used when updating data . |
23,972 | private Object initializeLazyPropertiesFromCache ( final String fieldName , final Object entity , final SharedSessionContractImplementor session , final EntityEntry entry , final CacheEntry cacheEntry ) { throw new NotSupportedException ( "OGM-9" , "Lazy properties not supported in OGM" ) ; } | Make superclasses method protected?? |
23,973 | public Object getCurrentVersion ( Serializable id , SharedSessionContractImplementor session ) throws HibernateException { if ( log . isTraceEnabled ( ) ) { log . trace ( "Getting version: " + MessageHelper . infoString ( this , id , getFactory ( ) ) ) ; } final Tuple resultset = getFreshTuple ( EntityKeyBuilder . fromPersister ( this , id , session ) , session ) ; if ( resultset == null ) { return null ; } else { return gridVersionType . nullSafeGet ( resultset , getVersionColumnName ( ) , session , null ) ; } } | Retrieve the version number |
23,974 | private boolean isAllOrDirtyOptLocking ( ) { EntityMetamodel entityMetamodel = getEntityMetamodel ( ) ; return entityMetamodel . getOptimisticLockStyle ( ) == OptimisticLockStyle . DIRTY || entityMetamodel . getOptimisticLockStyle ( ) == OptimisticLockStyle . ALL ; } | Copied from AbstractEntityPersister |
23,975 | private void removeFromInverseAssociations ( Tuple resultset , int tableIndex , Serializable id , SharedSessionContractImplementor session ) { new EntityAssociationUpdater ( this ) . id ( id ) . resultset ( resultset ) . session ( session ) . tableIndex ( tableIndex ) . propertyMightRequireInverseAssociationManagement ( propertyMightBeMainSideOfBidirectionalAssociation ) . removeNavigationalInformationFromInverseSide ( ) ; } | Removes the given entity from the inverse associations it manages . |
23,976 | private void addToInverseAssociations ( Tuple resultset , int tableIndex , Serializable id , SharedSessionContractImplementor session ) { new EntityAssociationUpdater ( this ) . id ( id ) . resultset ( resultset ) . session ( session ) . tableIndex ( tableIndex ) . propertyMightRequireInverseAssociationManagement ( propertyMightBeMainSideOfBidirectionalAssociation ) . addNavigationalInformationForInverseSide ( ) ; } | Adds the given entity to the inverse associations it manages . |
23,977 | private void processGeneratedProperties ( Serializable id , Object entity , Object [ ] state , SharedSessionContractImplementor session , GenerationTiming matchTiming ) { Tuple tuple = getFreshTuple ( EntityKeyBuilder . fromPersister ( this , id , session ) , session ) ; saveSharedTuple ( entity , tuple , session ) ; if ( tuple == null || tuple . getSnapshot ( ) . isEmpty ( ) ) { throw log . couldNotRetrieveEntityForRetrievalOfGeneratedProperties ( getEntityName ( ) , id ) ; } int propertyIndex = - 1 ; for ( NonIdentifierAttribute attribute : getEntityMetamodel ( ) . getProperties ( ) ) { propertyIndex ++ ; final ValueGeneration valueGeneration = attribute . getValueGenerationStrategy ( ) ; if ( isReadRequired ( valueGeneration , matchTiming ) ) { Object hydratedState = gridPropertyTypes [ propertyIndex ] . hydrate ( tuple , getPropertyAliases ( "" , propertyIndex ) , session , entity ) ; state [ propertyIndex ] = gridPropertyTypes [ propertyIndex ] . resolve ( hydratedState , session , entity ) ; setPropertyValue ( entity , propertyIndex , state [ propertyIndex ] ) ; } } } | Re - reads the given entity refreshing any properties updated on the server - side during insert or update . |
23,978 | private boolean isReadRequired ( ValueGeneration valueGeneration , GenerationTiming matchTiming ) { return valueGeneration != null && valueGeneration . getValueGenerator ( ) == null && timingsMatch ( valueGeneration . getGenerationTiming ( ) , matchTiming ) ; } | Whether the given value generation strategy requires to read the value from the database or not . |
23,979 | public static List < Object > listOfEntities ( SharedSessionContractImplementor session , Type [ ] resultTypes , ClosableIterator < Tuple > tuples ) { Class < ? > returnedClass = resultTypes [ 0 ] . getReturnedClass ( ) ; TupleBasedEntityLoader loader = getLoader ( session , returnedClass ) ; OgmLoadingContext ogmLoadingContext = new OgmLoadingContext ( ) ; ogmLoadingContext . setTuples ( getTuplesAsList ( tuples ) ) ; return loader . loadEntitiesFromTuples ( session , LockOptions . NONE , ogmLoadingContext ) ; } | At the moment we only support the case where one entity type is returned |
23,980 | private void doBatchWork ( BatchBackend backend ) throws InterruptedException { ExecutorService executor = Executors . newFixedThreadPool ( typesToIndexInParallel , "BatchIndexingWorkspace" ) ; for ( IndexedTypeIdentifier indexedTypeIdentifier : rootIndexedTypes ) { executor . execute ( new BatchIndexingWorkspace ( gridDialect , searchFactoryImplementor , sessionFactory , indexedTypeIdentifier , cacheMode , endAllSignal , monitor , backend , tenantId ) ) ; } executor . shutdown ( ) ; endAllSignal . await ( ) ; } | Will spawn a thread for each type in rootEntities they will all re - join on endAllSignal when finished . |
23,981 | private void afterBatch ( BatchBackend backend ) { IndexedTypeSet targetedTypes = searchFactoryImplementor . getIndexedTypesPolymorphic ( rootIndexedTypes ) ; if ( this . optimizeAtEnd ) { backend . optimize ( targetedTypes ) ; } backend . flush ( targetedTypes ) ; } | Operations to do after all subthreads finished their work on index |
23,982 | private void beforeBatch ( BatchBackend backend ) { if ( this . purgeAtStart ) { IndexedTypeSet targetedTypes = searchFactoryImplementor . getIndexedTypesPolymorphic ( rootIndexedTypes ) ; for ( IndexedTypeIdentifier type : targetedTypes ) { backend . doWorkInSync ( new PurgeAllLuceneWork ( tenantId , type ) ) ; } if ( this . optimizeAfterPurge ) { backend . optimize ( targetedTypes ) ; } } } | Optional operations to do before the multiple - threads start indexing |
23,983 | public static < T > Set < T > asSet ( T ... ts ) { if ( ts == null ) { return null ; } else if ( ts . length == 0 ) { return Collections . emptySet ( ) ; } else { Set < T > set = new HashSet < T > ( getInitialCapacityFromExpectedSize ( ts . length ) ) ; Collections . addAll ( set , ts ) ; return Collections . unmodifiableSet ( set ) ; } } | Returns an unmodifiable set containing the given elements . |
23,984 | private boolean isOrdinal ( int paramType ) { switch ( paramType ) { case Types . INTEGER : case Types . NUMERIC : case Types . SMALLINT : case Types . TINYINT : case Types . BIGINT : case Types . DECIMAL : case Types . DOUBLE : case Types . FLOAT : return true ; case Types . CHAR : case Types . LONGVARCHAR : case Types . VARCHAR : return false ; default : throw new HibernateException ( "Unable to persist an Enum in a column of SQL Type: " + paramType ) ; } } | in truth we probably only need the types as injected by the metadata binder |
23,985 | public ClosableIterator < Tuple > callStoredProcedure ( EmbeddedCacheManager embeddedCacheManager , String storedProcedureName , ProcedureQueryParameters queryParameters , ClassLoaderService classLoaderService ) { validate ( queryParameters ) ; Cache < String , String > cache = embeddedCacheManager . getCache ( STORED_PROCEDURES_CACHE_NAME , true ) ; String className = cache . getOrDefault ( storedProcedureName , storedProcedureName ) ; Callable < ? > callable = instantiate ( storedProcedureName , className , classLoaderService ) ; setParams ( storedProcedureName , queryParameters , callable ) ; Object res = execute ( storedProcedureName , embeddedCacheManager , callable ) ; return extractResultSet ( storedProcedureName , res ) ; } | Returns the result of a stored procedure executed on the backend . |
23,986 | public static String getPrefix ( String column ) { return column . contains ( "." ) ? DOT_SEPARATOR_PATTERN . split ( column ) [ 0 ] : null ; } | If the column name is a dotted column returns the first part . Returns null otherwise . |
23,987 | public static String getColumnSharedPrefix ( String [ ] associationKeyColumns ) { String prefix = null ; for ( String column : associationKeyColumns ) { String newPrefix = getPrefix ( column ) ; if ( prefix == null ) { prefix = newPrefix ; if ( prefix == null ) { break ; } } else { if ( ! equals ( prefix , newPrefix ) ) { prefix = null ; break ; } } } return prefix ; } | Returns the shared prefix of these columns . Null otherwise . |
23,988 | public static ThreadPoolExecutor newFixedThreadPool ( int threads , String groupname , int queueSize ) { return new ThreadPoolExecutor ( threads , threads , 0L , TimeUnit . MILLISECONDS , new LinkedBlockingQueue < Runnable > ( queueSize ) , new SearchThreadFactory ( groupname ) , new BlockPolicy ( ) ) ; } | Creates a new fixed size ThreadPoolExecutor |
23,989 | public static void readAndCheckVersion ( ObjectInput input , int supportedVersion , Class < ? > externalizedType ) throws IOException { int version = input . readInt ( ) ; if ( version != supportedVersion ) { throw LOG . unexpectedKeyVersion ( externalizedType , version , supportedVersion ) ; } } | Consumes the version field from the given input and raises an exception if the record is in a newer version written by a newer version of Hibernate OGM . |
23,990 | public static boolean matches ( Map < String , Object > nodeProperties , String [ ] keyColumnNames , Object [ ] keyColumnValues ) { for ( int i = 0 ; i < keyColumnNames . length ; i ++ ) { String property = keyColumnNames [ i ] ; Object expectedValue = keyColumnValues [ i ] ; boolean containsProperty = nodeProperties . containsKey ( property ) ; if ( containsProperty ) { Object actualValue = nodeProperties . get ( property ) ; if ( ! sameValue ( expectedValue , actualValue ) ) { return false ; } } else if ( expectedValue != null ) { return false ; } } return true ; } | Check if the node matches the column values |
23,991 | public GeoPolygon addHoles ( List < List < GeoPoint > > holes ) { Contracts . assertNotNull ( holes , "holes" ) ; this . rings . addAll ( holes ) ; return this ; } | Adds new holes to the polygon . |
23,992 | public void addAll ( OptionsContainerBuilder container ) { for ( Entry < Class < ? extends Option < ? , ? > > , ValueContainerBuilder < ? , ? > > entry : container . optionValues . entrySet ( ) ) { addAll ( entry . getKey ( ) , entry . getValue ( ) . build ( ) ) ; } } | Adds all options from the passed container to this container . |
23,993 | private static IndexedTypeSet toRootEntities ( ExtendedSearchIntegrator extendedIntegrator , Class < ? > ... selection ) { Set < Class < ? > > entities = new HashSet < Class < ? > > ( ) ; for ( Class < ? > entityType : selection ) { IndexedTypeSet targetedClasses = extendedIntegrator . getIndexedTypesPolymorphic ( IndexedTypeSets . fromClass ( entityType ) ) ; if ( targetedClasses . isEmpty ( ) ) { String msg = entityType . getName ( ) + " is not an indexed entity or a subclass of an indexed entity" ; throw new IllegalArgumentException ( msg ) ; } entities . addAll ( targetedClasses . toPojosSet ( ) ) ; } Set < Class < ? > > cleaned = new HashSet < Class < ? > > ( ) ; Set < Class < ? > > toRemove = new HashSet < Class < ? > > ( ) ; for ( Class < ? > type : entities ) { boolean typeIsOk = true ; for ( Class < ? > existing : cleaned ) { if ( existing . isAssignableFrom ( type ) ) { typeIsOk = false ; break ; } if ( type . isAssignableFrom ( existing ) ) { toRemove . add ( existing ) ; } } if ( typeIsOk ) { cleaned . add ( type ) ; } } cleaned . removeAll ( toRemove ) ; log . debugf ( "Targets for indexing job: %s" , cleaned ) ; return IndexedTypeSets . fromClasses ( cleaned . toArray ( new Class [ cleaned . size ( ) ] ) ) ; } | From the set of classes a new set is built containing all indexed subclasses but removing then all subtypes of indexed entities . |
23,994 | private void updateHostingEntityIfRequired ( ) { if ( hostingEntity != null && hostingEntityRequiresReadAfterUpdate ( ) ) { OgmEntityPersister entityPersister = getHostingEntityPersister ( ) ; if ( GridDialects . hasFacet ( gridDialect , GroupingByEntityDialect . class ) ) { ( ( GroupingByEntityDialect ) gridDialect ) . flushPendingOperations ( getAssociationKey ( ) . getEntityKey ( ) , entityPersister . getTupleContext ( session ) ) ; } entityPersister . processUpdateGeneratedProperties ( entityPersister . getIdentifier ( hostingEntity , session ) , hostingEntity , new Object [ entityPersister . getPropertyNames ( ) . length ] , session ) ; } } | Reads the entity hosting the association from the datastore and applies any property changes from the server side . |
23,995 | private static List < Class < ? > > getClassHierarchy ( Class < ? > clazz ) { List < Class < ? > > hierarchy = new ArrayList < Class < ? > > ( 4 ) ; for ( Class < ? > current = clazz ; current != null ; current = current . getSuperclass ( ) ) { hierarchy . add ( current ) ; } return hierarchy ; } | Returns the class hierarchy of the given type from bottom to top starting with the given class itself . Interfaces are not included . |
23,996 | public static PersistenceStrategy < ? , ? , ? > getInstance ( CacheMappingType cacheMapping , EmbeddedCacheManager externalCacheManager , URL configurationUrl , JtaPlatform jtaPlatform , Set < EntityKeyMetadata > entityTypes , Set < AssociationKeyMetadata > associationTypes , Set < IdSourceKeyMetadata > idSourceTypes ) { if ( cacheMapping == CacheMappingType . CACHE_PER_KIND ) { return getPerKindStrategy ( externalCacheManager , configurationUrl , jtaPlatform ) ; } else { return getPerTableStrategy ( externalCacheManager , configurationUrl , jtaPlatform , entityTypes , associationTypes , idSourceTypes ) ; } } | Returns a persistence strategy based on the passed configuration . |
23,997 | private Iterable < PersistentNoSqlIdentifierGenerator > getPersistentGenerators ( ) { Map < String , EntityPersister > entityPersisters = factory . getMetamodel ( ) . entityPersisters ( ) ; Set < PersistentNoSqlIdentifierGenerator > persistentGenerators = new HashSet < PersistentNoSqlIdentifierGenerator > ( entityPersisters . size ( ) ) ; for ( EntityPersister persister : entityPersisters . values ( ) ) { if ( persister . getIdentifierGenerator ( ) instanceof PersistentNoSqlIdentifierGenerator ) { persistentGenerators . add ( ( PersistentNoSqlIdentifierGenerator ) persister . getIdentifierGenerator ( ) ) ; } } return persistentGenerators ; } | Returns all the persistent id generators which potentially require the creation of an object in the schema . |
23,998 | public Relationship createRelationshipForEmbeddedAssociation ( GraphDatabaseService executionEngine , AssociationKey associationKey , EntityKey embeddedKey ) { String query = initCreateEmbeddedAssociationQuery ( associationKey , embeddedKey ) ; Object [ ] queryValues = createRelationshipForEmbeddedQueryValues ( associationKey , embeddedKey ) ; return executeQuery ( executionEngine , query , queryValues ) ; } | Give an embedded association creates all the nodes and relationships required to represent it . It assumes that the entity node containing the association already exists in the db . |
23,999 | private RowKeyAndTuple createAndPutAssociationRowForInsert ( Serializable key , PersistentCollection collection , AssociationPersister associationPersister , SharedSessionContractImplementor session , int i , Object entry ) { RowKeyBuilder rowKeyBuilder = initializeRowKeyBuilder ( ) ; Tuple associationRow = new Tuple ( ) ; if ( hasIdentifier ) { final Object identifier = collection . getIdentifier ( entry , i ) ; String [ ] names = { getIdentifierColumnName ( ) } ; identifierGridType . nullSafeSet ( associationRow , identifier , names , session ) ; } getKeyGridType ( ) . nullSafeSet ( associationRow , key , getKeyColumnNames ( ) , session ) ; if ( hasIndex ) { Object index = collection . getIndex ( entry , i , this ) ; indexGridType . nullSafeSet ( associationRow , incrementIndexByBase ( index ) , getIndexColumnNames ( ) , session ) ; } final Object element = collection . getElement ( entry ) ; getElementGridType ( ) . nullSafeSet ( associationRow , element , getElementColumnNames ( ) , session ) ; RowKeyAndTuple result = new RowKeyAndTuple ( ) ; result . key = rowKeyBuilder . values ( associationRow ) . build ( ) ; result . tuple = associationRow ; associationPersister . getAssociation ( ) . put ( result . key , result . tuple ) ; return result ; } | Creates an association row representing the given entry and adds it to the association managed by the given persister . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.