org.hibernate.cache.spi.access.SoftLock#org.hibernate.metamodel.spi.MetamodelImplementor源码实例Demo

下面列出了org.hibernate.cache.spi.access.SoftLock#org.hibernate.metamodel.spi.MetamodelImplementor 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: hibernate-reactive   文件: MutinySessionImpl.java
@Override
public <R> Mutiny.Query<R> createNativeQuery(String sql, Class<R> resultType) {
	final String typeName = resultType.getName();
	final MetamodelImplementor metamodel = delegate.getFactory().getMetamodel();
	final boolean knownType = metamodel.entityPersisters().containsKey( typeName );
	if ( knownType ) {
		return new MutinyQueryImpl<>( delegate.createReactiveNativeQuery( sql, resultType ) );
	}
	else {
		return new MutinyQueryImpl<>( delegate.createReactiveNativeQuery( sql ) );
	}
}
 
private void evictCachedCollections(Type[] types, Serializable id, EventSource source)
		throws HibernateException {
	final ActionQueue actionQueue = source.getActionQueue();
	final SessionFactoryImplementor factory = source.getFactory();
	final MetamodelImplementor metamodel = factory.getMetamodel();
	for ( Type type : types ) {
		if ( type.isCollectionType() ) {
			CollectionPersister collectionPersister = metamodel.collectionPersister( ( (CollectionType) type ).getRole() );
			if ( collectionPersister.hasCache() ) {
				final CollectionDataAccess cache = collectionPersister.getCacheAccessStrategy();
				final Object ck = cache.generateCacheKey(
					id,
					collectionPersister,
					factory,
					source.getTenantIdentifier()
				);
				final SoftLock lock = cache.lockItem( source, ck, null );
				cache.remove( source, ck );
				actionQueue.registerProcess( (success, session) -> cache.unlockItem( session, ck, lock ) );
			}
		}
		else if ( type.isComponentType() ) {
			CompositeType actype = (CompositeType) type;
			evictCachedCollections( actype.getSubtypes(), id, source );
		}
	}
}
 
源代码3 项目: lams   文件: TypeConfiguration.java
public MetamodelImplementor scope(SessionFactoryImplementor sessionFactory,  BootstrapContext bootstrapContext) {
	log.debugf( "Scoping TypeConfiguration [%s] to SessionFactoryImpl [%s]", this, sessionFactory );

	for ( Map.Entry<String, String> importEntry : scope.metadataBuildingContext.getMetadataCollector().getImports().entrySet() ) {
		if ( importMap.containsKey( importEntry.getKey() ) ) {
			continue;
		}

		importMap.put( importEntry.getKey(), importEntry.getValue() );
	}

	scope.setSessionFactory( sessionFactory );
	sessionFactory.addObserver( this );
	return new MetamodelImpl( sessionFactory, this );
}
 
源代码4 项目: dhis2-core   文件: DefaultSchemaService.java
@EventListener
public void handleContextRefresh( ContextRefreshedEvent contextRefreshedEvent )
{
    for ( SchemaDescriptor descriptor : descriptors )
    {
        Schema schema = descriptor.getSchema();

        MetamodelImplementor metamodelImplementor = (MetamodelImplementor) sessionFactory.getMetamodel();

        try
        {
            metamodelImplementor.entityPersister( schema.getKlass() );
            schema.setPersisted( true );
        }
        catch ( MappingException e )
        {
            // class is not persisted with Hibernate
            schema.setPersisted( false );
        }

        schema.setDisplayName( TextUtils.getPrettyClassName( schema.getKlass() ) );

        if ( schema.getProperties().isEmpty() )
        {
            schema.setPropertyMap( Maps.newHashMap( propertyIntrospectorService.getPropertiesMap( schema.getKlass() ) ) );
        }

        classSchemaMap.put( schema.getKlass(), schema );
        singularSchemaMap.put( schema.getSingular(), schema );
        pluralSchemaMap.put( schema.getPlural(), schema );

        updateSelf( schema );

        schema.getPersistedProperties();
        schema.getNonPersistedProperties();
        schema.getReadableProperties();
        schema.getEmbeddedObjectProperties();
    }
}
 
源代码5 项目: lams   文件: SessionFactoryImplementor.java
@Override
MetamodelImplementor getMetamodel();
 
源代码6 项目: lams   文件: SessionFactoryDelegatingImpl.java
@Override
public MetamodelImplementor getMetamodel() {
	return delegate.getMetamodel();
}
 
源代码7 项目: lams   文件: SessionImpl.java
@Override
public MetamodelImplementor getMetamodel() {
	checkOpen();
	return getFactory().getMetamodel();
}
 
源代码8 项目: lams   文件: SessionFactoryImpl.java
@Override
public MetamodelImplementor getMetamodel() {
	validateNotClosed();
	return metamodel;
}