org.hibernate.type.BasicType Java Examples

The following examples show how to use org.hibernate.type.BasicType. 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: ModelBinder.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private void resolveLob(final SingularAttributeSourceBasic attributeSource, SimpleValue value) {
	// Resolves whether the property is LOB based on the type attribute on the attribute property source.
	// Essentially this expects the type to map to a CLOB/NCLOB/BLOB sql type internally and compares.
	if ( !value.isLob() && value.getTypeName() != null ) {
		final TypeResolver typeResolver = attributeSource.getBuildingContext().getMetadataCollector().getTypeResolver();
		final BasicType basicType = typeResolver.basic( value.getTypeName() );
		if ( basicType instanceof AbstractSingleColumnStandardBasicType ) {
			if ( isLob( ( (AbstractSingleColumnStandardBasicType) basicType ).getSqlTypeDescriptor().getSqlType(), null ) ) {
				value.makeLob();
			}
		}
	}

	// If the prior check didn't set the lob flag, this will inspect the column sql-type attribute value and
	// if this maps to CLOB/NCLOB/BLOB then the value will be marked as lob.
	if ( !value.isLob() ) {
		for ( RelationalValueSource relationalValueSource : attributeSource.getRelationalValueSources() ) {
			if ( ColumnSource.class.isInstance( relationalValueSource ) ) {
				if ( isLob( null, ( (ColumnSource) relationalValueSource ).getSqlType() ) ) {
					value.makeLob();
				}
			}
		}
	}
}
 
Example #2
Source File: BindingTypeHelper.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public BasicType resolveTimestampTemporalTypeVariant(Class javaType, Type baseType) {
	// prefer to use any Type already known - interprets TIMESTAMP as "no narrowing"
	if ( baseType != null && baseType instanceof BasicType ) {
		return (BasicType) baseType;
	}

	if ( Calendar.class.isAssignableFrom( javaType ) ) {
		return CalendarType.INSTANCE;
	}

	if ( java.util.Date.class.isAssignableFrom( javaType ) ) {
		return TimestampType.INSTANCE;
	}

	if ( Instant.class.isAssignableFrom( javaType ) ) {
		return InstantType.INSTANCE;
	}

	if ( OffsetDateTime.class.isAssignableFrom( javaType ) ) {
		return OffsetDateTimeType.INSTANCE;
	}

	if ( ZonedDateTime.class.isAssignableFrom( javaType ) ) {
		return ZonedDateTimeType.INSTANCE;
	}

	if ( OffsetTime.class.isAssignableFrom( javaType ) ) {
		return OffsetTimeType.INSTANCE;
	}

	throw new IllegalArgumentException( "Unsure how to handle given Java type [" + javaType.getName() + "] as TemporalType#TIMESTAMP" );
}
 
Example #3
Source File: BindingTypeHelper.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public BasicType resolveDateTemporalTypeVariant(Class javaType, Type baseType) {
	// prefer to use any Type already known
	if ( baseType != null && baseType instanceof BasicType ) {
		if ( baseType.getReturnedClass().isAssignableFrom( javaType ) ) {
			return (BasicType) baseType;
		}
	}

	if ( Calendar.class.isAssignableFrom( javaType ) ) {
		return CalendarDateType.INSTANCE;
	}

	if ( java.util.Date.class.isAssignableFrom( javaType ) ) {
		return TimestampType.INSTANCE;
	}

	if ( Instant.class.isAssignableFrom( javaType ) ) {
		return OffsetDateTimeType.INSTANCE;
	}

	if ( OffsetDateTime.class.isAssignableFrom( javaType ) ) {
		return OffsetDateTimeType.INSTANCE;
	}

	if ( ZonedDateTime.class.isAssignableFrom( javaType ) ) {
		return ZonedDateTimeType.INSTANCE;
	}

	throw new IllegalArgumentException( "Unsure how to handle given Java type [" + javaType.getName() + "] as TemporalType#DATE" );
}
 
Example #4
Source File: BindingTypeHelper.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public BasicType resolveTimeTemporalTypeVariant(Class javaType, Type baseType) {
	if ( Calendar.class.isAssignableFrom( javaType ) ) {
		return CalendarTimeType.INSTANCE;
	}

	if ( java.util.Date.class.isAssignableFrom( javaType ) ) {
		return TimestampType.INSTANCE;
	}

	throw new IllegalArgumentException( "Unsure how to handle given Java type [" + javaType.getName() + "] as TemporalType#TIME" );
}
 
Example #5
Source File: ExportableColumn.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public ExportableColumn(Database database, Table table, String name, BasicType type) {
	this(
			database,
			table,
			name,
			type,
			database.getDialect().getTypeName( type.sqlTypes( null )[0] )
	);
}
 
Example #6
Source File: ExportableColumn.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public ExportableColumn(
		Database database,
		Table table,
		String name,
		BasicType type,
		String dbTypeDeclaration) {
	super( name );
	setValue( new ValueImpl( this, table, type, database ) );
	setSqlType( dbTypeDeclaration );
}
 
Example #7
Source File: AbstractTest.java    From hibernate-types with Apache License 2.0 5 votes vote down vote up
protected EntityManagerFactory newEntityManagerFactory() {
    PersistenceUnitInfo persistenceUnitInfo = persistenceUnitInfo(getClass().getSimpleName());
    Map<String, Object> configuration = new HashMap<>();
    configuration.put(AvailableSettings.INTERCEPTOR, interceptor());
    Integrator integrator = integrator();
    if (integrator != null) {
        configuration.put("hibernate.integrator_provider", (IntegratorProvider) () -> Collections.singletonList(integrator));
    }

    final List<Type> additionalTypes = additionalTypes();
    if (additionalTypes != null) {
        configuration.put("hibernate.type_contributors", (TypeContributorList) () -> {
            List<TypeContributor> typeContributors = new ArrayList<>();

            for (Type additionalType : additionalTypes) {
                if (additionalType instanceof BasicType) {
                    typeContributors.add((typeContributions, serviceRegistry) -> typeContributions.contributeType((BasicType) additionalType));


                } else if (additionalType instanceof UserType) {
                    typeContributors.add((typeContributions, serviceRegistry) -> typeContributions.contributeType((UserType) additionalType));
                } else if (additionalType instanceof CompositeUserType) {
                    typeContributors.add((typeContributions, serviceRegistry) -> typeContributions.contributeType((CompositeUserType) additionalType));
                }
            }
            return typeContributors;
        });
    }

    EntityManagerFactoryBuilderImpl entityManagerFactoryBuilder = new EntityManagerFactoryBuilderImpl(
            new PersistenceUnitInfoDescriptor(persistenceUnitInfo), configuration
    );
    return entityManagerFactoryBuilder.build();
}
 
Example #8
Source File: TypeLocatorImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example #9
Source File: AbstractTest.java    From hibernate-types with Apache License 2.0 4 votes vote down vote up
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()
    );
}
 
Example #10
Source File: MetadataBuilderImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public MetadataBuilder applyBasicType(BasicType type) {
	options.basicTypeRegistrations.add( new BasicTypeRegistration( type ) );
	return this;
}
 
Example #11
Source File: MetadataBuilderImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public MetadataBuilder applyBasicType(BasicType type, String... keys) {
	options.basicTypeRegistrations.add( new BasicTypeRegistration( type, keys ) );
	return this;
}
 
Example #12
Source File: MetadataBuilderImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void contributeType(BasicType type) {
	options.basicTypeRegistrations.add( new BasicTypeRegistration( type ) );
}
 
Example #13
Source File: MetadataBuilderImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void contributeType(BasicType type, String... keys) {
	options.basicTypeRegistrations.add( new BasicTypeRegistration( type, keys ) );
}
 
Example #14
Source File: AbstractTest.java    From hibernate-types with Apache License 2.0 4 votes vote down vote up
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();
}
 
Example #15
Source File: AbstractTest.java    From hibernate-types with Apache License 2.0 4 votes vote down vote up
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()
    );
}
 
Example #16
Source File: BasicTypeRegistration.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public BasicTypeRegistration(BasicType basicType, String[] registrationKeys) {
	this.basicType = basicType;
	this.registrationKeys = registrationKeys;
}
 
Example #17
Source File: AbstractTest.java    From hibernate-types with Apache License 2.0 4 votes vote down vote up
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()
    );
}
 
Example #18
Source File: HibernateQuery.java    From gorm-hibernate5 with Apache License 2.0 4 votes vote down vote up
protected String render(BasicType basic, List<String> columns, SessionFactory sessionFactory, SQLFunction sqlFunction) {
    return sqlFunction.render(basic, columns, (SessionFactoryImplementor) sessionFactory);
}
 
Example #19
Source File: AbstractTest.java    From high-performance-java-persistence with Apache License 2.0 4 votes vote down vote up
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()
    .enableNewIdentifierGeneratorSupport(true)
    .applyImplicitNamingStrategy(ImplicitNamingStrategyLegacyJpaImpl.INSTANCE);

    final List<Type> additionalTypes = additionalTypes();
    if (additionalTypes != null) {
        additionalTypes.stream().forEach(type -> {
            metadataBuilder.applyTypes((typeContributions, sr) -> {
                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);
                }
            });
        });
    }

    additionalMetadata(metadataBuilder);

    MetadataImplementor metadata = (MetadataImplementor) metadataBuilder.build();

    final SessionFactoryBuilder sfb = metadata.getSessionFactoryBuilder();
    Interceptor interceptor = interceptor();
    if(interceptor != null) {
        sfb.applyInterceptor(interceptor);
    }

    return sfb.build();
}
 
Example #20
Source File: AbstractTest.java    From high-performance-java-persistence with Apache License 2.0 4 votes vote down vote up
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()
    );
}
 
Example #21
Source File: J2CacheMessageLogger_$logger.java    From J2Cache with Apache License 2.0 4 votes vote down vote up
public final void typeDefinedNoRegistrationKeys(BasicType arg0) {
    super.log.logf(FQCN, Logger.Level.WARN, (Throwable)null, this.typeDefinedNoRegistrationKeys$str(), arg0);
}
 
Example #22
Source File: J2CacheMessageLogger_$logger.java    From J2Cache with Apache License 2.0 4 votes vote down vote up
public final void typeDefinedNoRegistrationKeys(final BasicType arg0) {
    super.log.logf(FQCN, (org.jboss.logging.Logger.Level.WARN), null, typeDefinedNoRegistrationKeys$str(), arg0);
}
 
Example #23
Source File: BasicTypeRegistration.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public BasicTypeRegistration(BasicType basicType) {
	this( basicType, basicType.getRegistrationKeys() );
}
 
Example #24
Source File: AbstractDelegatingMetadataBuilderImplementor.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public MetadataBuilder applyBasicType(BasicType type, String... keys) {
	delegate.applyBasicType( type, keys );
	return getThis();
}
 
Example #25
Source File: AbstractDelegatingMetadataBuilderImplementor.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public MetadataBuilder applyBasicType(BasicType type) {
	delegate.applyBasicType( type );
	return getThis();
}
 
Example #26
Source File: Configuration.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create a {@link SessionFactory} using the properties and mappings in this configuration. The
 * SessionFactory will be immutable, so changes made to this Configuration after building the
 * SessionFactory will not affect it.
 *
 * @param serviceRegistry The registry of services to be used in creating this session factory.
 *
 * @return The built {@link SessionFactory}
 *
 * @throws HibernateException usually indicates an invalid configuration or invalid mapping information
 */
public SessionFactory buildSessionFactory(ServiceRegistry serviceRegistry) throws HibernateException {
	log.debug( "Building session factory using provided StandardServiceRegistry" );
	final MetadataBuilder metadataBuilder = metadataSources.getMetadataBuilder( (StandardServiceRegistry) serviceRegistry );
	if ( implicitNamingStrategy != null ) {
		metadataBuilder.applyImplicitNamingStrategy( implicitNamingStrategy );
	}
	if ( physicalNamingStrategy != null ) {
		metadataBuilder.applyPhysicalNamingStrategy( physicalNamingStrategy );
	}
	if ( sharedCacheMode != null ) {
		metadataBuilder.applySharedCacheMode( sharedCacheMode );
	}
	if ( !typeContributorRegistrations.isEmpty() ) {
		for ( TypeContributor typeContributor : typeContributorRegistrations ) {
			metadataBuilder.applyTypes( typeContributor );
		}
	}
	if ( !basicTypes.isEmpty() ) {
		for ( BasicType basicType : basicTypes ) {
			metadataBuilder.applyBasicType( basicType );
		}
	}
	if ( sqlFunctions != null ) {
		for ( Map.Entry<String, SQLFunction> entry : sqlFunctions.entrySet() ) {
			metadataBuilder.applySqlFunction( entry.getKey(), entry.getValue() );
		}
	}
	if ( auxiliaryDatabaseObjectList != null ) {
		for ( AuxiliaryDatabaseObject auxiliaryDatabaseObject : auxiliaryDatabaseObjectList ) {
			metadataBuilder.applyAuxiliaryDatabaseObject( auxiliaryDatabaseObject );
		}
	}
	if ( attributeConverterDefinitionsByClass != null ) {
		for ( AttributeConverterDefinition attributeConverterDefinition : attributeConverterDefinitionsByClass.values() ) {
			metadataBuilder.applyAttributeConverter( attributeConverterDefinition );
		}
	}

	final Metadata metadata = metadataBuilder.build();

	final SessionFactoryBuilder sessionFactoryBuilder = metadata.getSessionFactoryBuilder();
	if ( interceptor != null && interceptor != EmptyInterceptor.INSTANCE ) {
		sessionFactoryBuilder.applyInterceptor( interceptor );
	}
	if ( getSessionFactoryObserver() != null ) {
		sessionFactoryBuilder.addSessionFactoryObservers( getSessionFactoryObserver() );
	}
	if ( getEntityNotFoundDelegate() != null ) {
		sessionFactoryBuilder.applyEntityNotFoundDelegate( getEntityNotFoundDelegate() );
	}
	if ( getEntityTuplizerFactory() != null ) {
		sessionFactoryBuilder.applyEntityTuplizerFactory( getEntityTuplizerFactory() );
	}
	if ( getCurrentTenantIdentifierResolver() != null ) {
		sessionFactoryBuilder.applyCurrentTenantIdentifierResolver( getCurrentTenantIdentifierResolver() );
	}

	return sessionFactoryBuilder.build();
}
 
Example #27
Source File: BindingTypeHelper.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public BasicType determineTypeForTemporalType(TemporalType temporalType, Type baseType, Object bindValue) {
	// todo : for 6.0 make TemporalType part of org.hibernate.type.descriptor.java.JdbcRecommendedSqlTypeMappingContext
	//		then we can just ask the org.hibernate.type.basic.BasicTypeFactory to handle this based on its registry
	//
	//   - or for 6.0 make TemporalType part of the state for those BasicType impls dealing with date/time types
	//
	// 	 - or for 6.0 make TemporalType part of Binder contract
	//
	//   - or add a org.hibernate.type.TemporalType#getVariant(TemporalType)
	//
	//	 - or ...

	// todo : (5.2) review Java type handling for sanity.  This part was done quickly ;)

	final Class javaType;

	// Determine the "value java type" :
	// 		prefer to leverage the bindValue java type (if bindValue not null),
	// 		followed by the java type reported by the baseType,
	// 		fallback to java.sql.Timestamp

	if ( bindValue != null ) {
		javaType = bindValue.getClass();
	}
	else if ( baseType != null ) {
		javaType = baseType.getReturnedClass();
	}
	else {
		javaType = java.sql.Timestamp.class;
	}

	switch ( temporalType ) {
		case TIMESTAMP: {
			return resolveTimestampTemporalTypeVariant( javaType, baseType );
		}
		case DATE: {
			return resolveDateTemporalTypeVariant( javaType, baseType );
		}
		case TIME: {
			return resolveTimeTemporalTypeVariant( javaType, baseType );
		}
		default: {
			throw new IllegalArgumentException( "Unexpected TemporalType [" + temporalType + "]; expecting TIMESTAMP, DATE or TIME" );
		}
	}
}
 
Example #28
Source File: BasicTypeRegistration.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public BasicType getBasicType() {
	return basicType;
}
 
Example #29
Source File: ExportableColumn.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public ValueImpl(ExportableColumn column, Table table, BasicType type, Database database) {
	this.column = column;
	this.table = table;
	this.type = type;
	this.database = database;
}
 
Example #30
Source File: CoreMessageLogger.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@LogMessage(level = WARN)
@Message(value = "Type [%s] defined no registration keys; ignoring", id = 269)
void typeDefinedNoRegistrationKeys(BasicType type);