org.hibernate.metamodel.spi.MetamodelImplementor Java Examples

The following examples show how to use org.hibernate.metamodel.spi.MetamodelImplementor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MutinySessionImpl.java    From hibernate-reactive with GNU Lesser General Public License v2.1 5 votes vote down vote up
@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 ) );
	}
}
 
Example #2
Source File: DefaultReactiveRefreshEventListener.java    From hibernate-reactive with GNU Lesser General Public License v2.1 5 votes vote down vote up
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 );
		}
	}
}
 
Example #3
Source File: TypeConfiguration.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
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 );
}
 
Example #4
Source File: DefaultSchemaService.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@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();
    }
}
 
Example #5
Source File: SessionFactoryImplementor.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
MetamodelImplementor getMetamodel();
 
Example #6
Source File: SessionFactoryDelegatingImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public MetamodelImplementor getMetamodel() {
	return delegate.getMetamodel();
}
 
Example #7
Source File: SessionImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public MetamodelImplementor getMetamodel() {
	checkOpen();
	return getFactory().getMetamodel();
}
 
Example #8
Source File: SessionFactoryImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public MetamodelImplementor getMetamodel() {
	validateNotClosed();
	return metamodel;
}