public ExtendedAnnotationConfiguration(ExtendedDialect dialect) { Iterable<? extends BasicType> types = dialect.getExtraTypeOverrides(); for( BasicType basicType : types ) { registerTypeOverride(basicType); } }
private static void resolveAndBindTypeDef(SimpleValue simpleValue, Mappings mappings, String typeName, Properties parameters) { TypeDef typeDef = mappings.getTypeDef( typeName ); if ( typeDef != null ) { typeName = typeDef.getTypeClass(); // parameters on the property mapping should // override parameters in the typedef Properties allParameters = new Properties(); allParameters.putAll( typeDef.getParameters() ); allParameters.putAll( parameters ); parameters = allParameters; }else if (typeName!=null && !mappings.isInSecondPass()){ BasicType basicType=mappings.getTypeResolver().basic(typeName); if (basicType==null) { /* * If the referenced typeName isn't a basic-type, it's probably a typedef defined * in a mapping file not read yet. * It should be solved by deferring the resolution and binding of this type until * all mapping files are read - the second passes. * Fixes issue HHH-7300 */ SecondPass resolveUserTypeMappingSecondPass=new ResolveUserTypeMappingSecondPass(simpleValue,typeName,mappings,parameters); mappings.addSecondPass(resolveUserTypeMappingSecondPass); } } if ( !parameters.isEmpty() ) simpleValue.setTypeParameters( parameters ); if ( typeName != null ) simpleValue.setTypeName( typeName ); }
@Override public BasicType basic(Class javaType) { BasicType type = typeResolver.basic( javaType.getName() ); if ( type == null ) { final Class variant = resolvePrimitiveOrPrimitiveWrapperVariantJavaType( javaType ); if ( variant != null ) { type = typeResolver.basic( variant.getName() ); } } return type; }
/** * REVISAR NIKOLAS */ @Override public Type getType(Criteria subcriteria, String propertyName) throws HibernateException { System.out.println("Prperty name ==> "+propertyName); BasicType _type = ((SessionFactoryImpl) sessionFactory).getTypeResolver() .basic(rootCriteria.getMapColumns().get(propertyName).getType().getName()); /*return getPropertyMapping( getEntityName( subcriteria, propertyName ) ) .toType( getPropertyName( propertyName ) );*/ return _type; }
public static <T> Type convert( PersisterCreationContext creationContext, ManagedTypeImplementor source, String navigableName, Value valueBinding, TypeConfiguration typeConfiguration) { if ( valueBinding.getType() == null ) { return null; } if ( valueBinding.getType() instanceof org.hibernate.type.BasicType ) { return convertBasic( (BasicType) valueBinding.getType(), typeConfiguration ); } if ( valueBinding.getType() instanceof org.hibernate.type.CompositeType ) { return convertEmbedded( creationContext, source, navigableName, (Component) valueBinding, typeConfiguration ); } if ( valueBinding.getType() instanceof org.hibernate.type.CollectionType ) { return convertCollection( creationContext, source, navigableName, (Collection) valueBinding, typeConfiguration ); } if ( valueBinding.getType() instanceof org.hibernate.type.ManyToOneType ) { return convertEntity( creationContext, source, navigableName, (ToOne) valueBinding, typeConfiguration ); } throw new NotYetImplementedException( "Converting " + valueBinding.getType().getClass().getName() + " -> org.hibernate.orm.type.spi.Type" ); }
@Override public Iterable<? extends BasicType> getExtraTypeOverrides() { return ImmutableList.of(TYPE_BLANKABLE, TYPE_CSV, TYPE_XSTREAM); }
@Override public Iterable<? extends BasicType> getExtraTypeOverrides() { return ImmutableList.of(new TextClobType(), TYPE_XSTREAM, TYPE_CSV, TYPE_BLANKABLE); }
@Override public Iterable<? extends BasicType> getExtraTypeOverrides() { return tenG.getExtraTypeOverrides(); }
@Override public Iterable<? extends BasicType> getExtraTypeOverrides() { return ImmutableList.of(new NStringType(), new LongNStringType(), TYPE_BLANKABLE, TYPE_XSTREAM, TYPE_CSV); }
@Override public BasicType basic(String name) { return typeResolver.basic( name ); }
@LogMessage(level = WARN) @Message(value = "Type [%s] defined no registration keys; ignoring", id = 269) void typeDefinedNoRegistrationKeys(BasicType type);
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((typeContributions, serviceRegistry) -> { additionalTypes.stream().forEach(type -> { 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() ); }
private SessionFactory newSessionFactory() { 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, new String[]{type.getName()}); } else if (type instanceof CompositeUserType) { typeContributions.contributeType((CompositeUserType) type, new String[]{type.getName()}); } } } }); } return configuration.buildSessionFactory( new StandardServiceRegistryBuilder() .applySettings(properties) .build() ); }
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() ); }
protected String render(BasicType basic, List<String> columns, SessionFactory sessionFactory, SQLFunction sqlFunction) { return sqlFunction.render(basic, columns, (SessionFactoryImplementor) sessionFactory); }
@SuppressWarnings("unchecked") public static org.hibernate.orm.type.spi.BasicType convertBasic(Property mappingProperty, TypeConfiguration typeConfiguration) { return typeConfiguration.getBasicTypeRegistry().getBasicType( mappingProperty.getType().getReturnedClass() ); }
private SessionFactory newSessionFactory() { final BootstrapServiceRegistryBuilder bsrb = new BootstrapServiceRegistryBuilder() .enableAutoClose(); Integrator integrator = integrator(); if (integrator != null) { bsrb.applyIntegrator( integrator ); } final BootstrapServiceRegistry bsr = bsrb.build(); final StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder(bsr) .applySettings(properties()) .build(); final MetadataSources metadataSources = new MetadataSources(serviceRegistry); for (Class annotatedClass : entities()) { metadataSources.addAnnotatedClass(annotatedClass); } String[] packages = packages(); if (packages != null) { for (String annotatedPackage : packages) { metadataSources.addPackage(annotatedPackage); } } String[] resources = resources(); if (resources != null) { for (String resource : resources) { metadataSources.addResource(resource); } } final MetadataBuilder metadataBuilder = metadataSources.getMetadataBuilder(); metadataBuilder.enableNewIdentifierGeneratorSupport(true); metadataBuilder.applyImplicitNamingStrategy(ImplicitNamingStrategyLegacyJpaImpl.INSTANCE); final List<Type> additionalTypes = additionalTypes(); if (additionalTypes != null) { additionalTypes.stream().forEach(type -> { metadataBuilder.applyTypes((typeContributions, serviceRegistry1) -> { 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); } }); }); } MetadataImplementor metadata = (MetadataImplementor) metadataBuilder.build(); final SessionFactoryBuilder sfb = metadata.getSessionFactoryBuilder(); Interceptor interceptor = interceptor(); if(interceptor != null) { sfb.applyInterceptor(interceptor); } return sfb.build(); }
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((typeContributions, serviceRegistry) -> { additionalTypes.stream().forEach(type -> { 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() ); }
/** * This method is here because of a bug in hibernate. Types are cached * before the dialect has a say in it, thus buggering up some of our Lob * types. * * @return */ Iterable<? extends BasicType> getExtraTypeOverrides();
/** * Allows registration of a type into the type registry. The phrase 'override' in the method name simply * reminds that registration *potentially* replaces a previously registered type . * * @param type The type to register. */ public void registerTypeOverride(BasicType type) { getTypeResolver().registerTypeOverride( type ); }
/** * Retrieve the basic type registered against the given name. * * @param name The name of the basic type to retrieve * * @return The basic type, or null. */ public BasicType basic(String name);
/** * Convenience form of {@link #basic(String)}. The intended use of this is something like * {@code basic(Integer.class)} or {@code basic(int.class)} * * @param javaType The java type for which to retrieve the type instance. * * @return The basic type, or null. */ public BasicType basic(Class javaType);
public void contributeType(BasicType type);