use of org.hibernate.usertype.CompositeUserType in project hibernate-orm by hibernate.
the class MetadataBuildingProcess method handleTypes.
// private static JandexInitManager buildJandexInitializer(
// MetadataBuildingOptions options,
// ClassLoaderAccess classLoaderAccess) {
// final boolean autoIndexMembers = ConfigurationHelper.getBoolean(
// org.hibernate.cfg.AvailableSettings.ENABLE_AUTO_INDEX_MEMBER_TYPES,
// options.getServiceRegistry().getService( ConfigurationService.class ).getSettings(),
// false
// );
//
// return new JandexInitManager( options.getJandexView(), classLoaderAccess, autoIndexMembers );
// }
private static BasicTypeRegistry handleTypes(MetadataBuildingOptions options) {
final ClassLoaderService classLoaderService = options.getServiceRegistry().getService(ClassLoaderService.class);
// ultimately this needs to change a little bit to account for HHH-7792
final BasicTypeRegistry basicTypeRegistry = new BasicTypeRegistry();
final TypeContributions typeContributions = new TypeContributions() {
@Override
public void contributeType(org.hibernate.type.BasicType type) {
basicTypeRegistry.register(type);
}
@Override
public void contributeType(BasicType type, String... keys) {
basicTypeRegistry.register(type, keys);
}
@Override
public void contributeType(UserType type, String[] keys) {
basicTypeRegistry.register(type, keys);
}
@Override
public void contributeType(CompositeUserType type, String[] keys) {
basicTypeRegistry.register(type, keys);
}
};
// add Dialect contributed types
final Dialect dialect = options.getServiceRegistry().getService(JdbcServices.class).getDialect();
dialect.contributeTypes(typeContributions, options.getServiceRegistry());
// add TypeContributor contributed types.
for (TypeContributor contributor : classLoaderService.loadJavaServices(TypeContributor.class)) {
contributor.contribute(typeContributions, options.getServiceRegistry());
}
// add explicit application registered types
for (BasicTypeRegistration basicTypeRegistration : options.getBasicTypeRegistrations()) {
basicTypeRegistry.register(basicTypeRegistration.getBasicType(), basicTypeRegistration.getRegistrationKeys());
}
return basicTypeRegistry;
}
use of org.hibernate.usertype.CompositeUserType in project hibernate-orm by hibernate.
the class MetadataBuildingProcess method handleTypes.
// todo (7.0) : buildJandexInitializer
// private static JandexInitManager buildJandexInitializer(
// MetadataBuildingOptions options,
// ClassLoaderAccess classLoaderAccess) {
// final boolean autoIndexMembers = ConfigurationHelper.getBoolean(
// org.hibernate.cfg.AvailableSettings.ENABLE_AUTO_INDEX_MEMBER_TYPES,
// options.getServiceRegistry().getService( ConfigurationService.class ).getSettings(),
// false
// );
//
// return new JandexInitManager( options.getJandexView(), classLoaderAccess, autoIndexMembers );
// }
private static void handleTypes(BootstrapContext bootstrapContext, MetadataBuildingOptions options) {
final ClassLoaderService classLoaderService = options.getServiceRegistry().getService(ClassLoaderService.class);
final TypeContributions typeContributions = new TypeContributions() {
@Override
public void contributeType(org.hibernate.type.BasicType type) {
getBasicTypeRegistry().register(type);
}
@Override
public void contributeType(BasicType type, String... keys) {
getBasicTypeRegistry().register(type, keys);
}
@Override
public void contributeType(UserType type, String[] keys) {
getBasicTypeRegistry().register(type, keys);
}
@Override
public void contributeType(CompositeUserType type, String[] keys) {
getBasicTypeRegistry().register(type, keys);
}
@Override
public void contributeJavaTypeDescriptor(JavaTypeDescriptor descriptor) {
bootstrapContext.getTypeConfiguration().getJavaTypeDescriptorRegistry().addDescriptor(descriptor);
}
@Override
public void contributeSqlTypeDescriptor(SqlTypeDescriptor descriptor) {
bootstrapContext.getTypeConfiguration().getSqlTypeDescriptorRegistry().addDescriptor(descriptor);
}
@Override
public TypeConfiguration getTypeConfiguration() {
return bootstrapContext.getTypeConfiguration();
}
final BasicTypeRegistry getBasicTypeRegistry() {
return bootstrapContext.getTypeConfiguration().getBasicTypeRegistry();
}
};
// add Dialect contributed types
final Dialect dialect = options.getServiceRegistry().getService(JdbcServices.class).getDialect();
dialect.contributeTypes(typeContributions, options.getServiceRegistry());
// add TypeContributor contributed types.
for (TypeContributor contributor : classLoaderService.loadJavaServices(TypeContributor.class)) {
contributor.contribute(typeContributions, options.getServiceRegistry());
}
// add explicit application registered types
for (BasicTypeRegistration basicTypeRegistration : options.getBasicTypeRegistrations()) {
bootstrapContext.getTypeConfiguration().getBasicTypeRegistry().register(basicTypeRegistration.getBasicType(), basicTypeRegistration.getRegistrationKeys());
}
}
use of org.hibernate.usertype.CompositeUserType in project hibernate-orm by hibernate.
the class TypeFactory method customComponent.
/**
* @deprecated Only for use temporary use by {@link org.hibernate.Hibernate}
*/
@Deprecated
@SuppressWarnings({ "JavaDoc" })
public static CompositeCustomType customComponent(Class<CompositeUserType> typeClass, Properties parameters, TypeScope scope) {
try {
CompositeUserType userType = typeClass.newInstance();
injectParameters(userType, parameters);
return new CompositeCustomType(userType);
} catch (Exception e) {
throw new MappingException("Unable to instantiate custom type: " + typeClass.getName(), e);
}
}
Aggregations