下面列出了org.hibernate.cache.spi.access.SoftLock#org.hibernate.metamodel.spi.MetamodelImplementor 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@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 );
}
}
}
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 );
}
@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();
}
}
@Override
MetamodelImplementor getMetamodel();
@Override
public MetamodelImplementor getMetamodel() {
return delegate.getMetamodel();
}
@Override
public MetamodelImplementor getMetamodel() {
checkOpen();
return getFactory().getMetamodel();
}
@Override
public MetamodelImplementor getMetamodel() {
validateNotClosed();
return metamodel;
}