org.hibernate.usertype.UserType#org.hibernate.boot.model.TypeContributions源码实例Demo

下面列出了org.hibernate.usertype.UserType#org.hibernate.boot.model.TypeContributions 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: lams   文件: Oracle12cDialect.java
@Override
public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
	super.contributeTypes( typeContributions, serviceRegistry );

	// account for Oracle's deprecated support for LONGVARBINARY...
	// 		prefer BLOB, unless the user opts out of it
	boolean preferLong = serviceRegistry.getService( ConfigurationService.class ).getSetting(
			PREFER_LONG_RAW,
			StandardConverters.BOOLEAN,
			false
	);

	if ( !preferLong ) {
		typeContributions.contributeType( MaterializedBlobType.INSTANCE, "byte[]", byte[].class.getName() );
		typeContributions.contributeType( WrappedMaterializedBlobType.INSTANCE, "Byte[]", Byte[].class.getName() );
	}
}
 
@Override
protected void additionalProperties(Properties properties) {
    CustomObjectMapperSupplier customObjectMapperSupplier = new CustomObjectMapperSupplier();
    final JsonBinaryType jsonBinaryType = new JsonBinaryType(customObjectMapperSupplier.get(), Location.class);

    properties.put( "hibernate.type_contributors", new TypeContributorList() {
        @Override
        public List<TypeContributor> getTypeContributors() {
            List<TypeContributor> typeContributors = new ArrayList<TypeContributor>();
            typeContributors.add(new TypeContributor() {
                @Override
                public void contribute(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
                    typeContributions.contributeType(
                        jsonBinaryType, "location"
                    );
                }
            });
            return typeContributors;
        }
    });
}
 
源代码3 项目: lams   文件: PostgreSQL82Dialect.java
@Override
public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
	super.contributeTypes( typeContributions, serviceRegistry );

	// HHH-9562
	typeContributions.contributeType( PostgresUUIDType.INSTANCE );
}
 
源代码4 项目: nomulus   文件: NomulusPostgreSQLDialect.java
@Override
public void contributeTypes(
    TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
  super.contributeTypes(typeContributions, serviceRegistry);
  typeContributions.contributeJavaTypeDescriptor(StringCollectionDescriptor.getInstance());
  typeContributions.contributeSqlTypeDescriptor(StringCollectionDescriptor.getInstance());
  typeContributions.contributeJavaTypeDescriptor(StringMapDescriptor.getInstance());
  typeContributions.contributeSqlTypeDescriptor(StringMapDescriptor.getInstance());
}
 
@Override
protected void additionalProperties(Properties properties) {
    TypeContributor typeContributor = new TypeContributor() {
        @Override
        public void contribute(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
            typeContributions.contributeType(JsonNodeBinaryType.INSTANCE);
            typeContributions.contributeSqlTypeDescriptor(JsonNodeBinaryType.INSTANCE                       .getSqlTypeDescriptor());
        }
    };
    properties.put(
            "hibernate.type_contributors",
            (TypeContributorList) () -> Collections.singletonList(typeContributor)
    );
}
 
@Override
public void contribute(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
	if ( ReactiveModeCheck.isReactiveRegistry( serviceRegistry ) ) {
		registerReactiveChanges( typeContributions, serviceRegistry );
	}
}
 
private void registerReactiveChanges(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
	BasicTypeRegistry basicTypeRegistry = typeContributions.getTypeConfiguration().getBasicTypeRegistry();
	Dialect dialect = serviceRegistry.getService(JdbcEnvironment.class).getDialect();
	basicTypeRegistry.register( new BlobType(dialect) );
	basicTypeRegistry.register( new ClobType(dialect) );
}
 
源代码8 项目: hibernate-types   文件: AbstractTest.java
private SessionFactory newLegacySessionFactory() {
    Properties properties = properties();
    Configuration configuration = new Configuration().addProperties(properties);
    for (Class<?> entityClass : entities()) {
        configuration.addAnnotatedClass(entityClass);
    }
    String[] packages = packages();
    if (packages != null) {
        for (String scannedPackage : packages) {
            configuration.addPackage(scannedPackage);
        }
    }
    String[] resources = resources();
    if (resources != null) {
        for (String resource : resources) {
            configuration.addResource(resource);
        }
    }
    Interceptor interceptor = interceptor();
    if (interceptor != null) {
        configuration.setInterceptor(interceptor);
    }

    final List<Type> additionalTypes = additionalTypes();
    if (additionalTypes != null) {
        configuration.registerTypeContributor(new TypeContributor() {
            @Override
            public void contribute(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
                for (Type type : additionalTypes) {
                    if (type instanceof BasicType) {
                        typeContributions.contributeType((BasicType) type);
                    } else if (type instanceof UserType) {
                        typeContributions.contributeType((UserType) type);
                    } else if (type instanceof CompositeUserType) {
                        typeContributions.contributeType((CompositeUserType) type);
                    }
                }
            }
        });
    }
    return configuration.buildSessionFactory(
            new StandardServiceRegistryBuilder()
                    .applySettings(properties)
                    .build()
    );
}
 
源代码9 项目: hibernate-demos   文件: TestTypeContributor.java
@Override
   public void contribute(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
	System.out.println("TypeContributor#contribute");
}
 
源代码10 项目: hibernate-demos   文件: TestTypeContributor.java
@Override
   public void contribute(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
	System.out.println("TypeContributor#contribute");
}
 
源代码11 项目: keycloak   文件: DelegatingDialect.java
@Override
public void contributeTypes(TypeContributions typeContributions,
        ServiceRegistry serviceRegistry) {
    getInstance().contributeTypes(typeContributions, serviceRegistry);
}
 
源代码12 项目: lams   文件: Dialect.java
/**
 * Allows the Dialect to contribute additional types
 *
 * @param typeContributions Callback to contribute the types
 * @param serviceRegistry The service registry
 */
public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
	resolveLegacyLimitHandlerBehavior( serviceRegistry );
}