org.hibernate.type.descriptor.java.JavaTypeDescriptor Java Examples
The following examples show how to use
org.hibernate.type.descriptor.java.JavaTypeDescriptor.
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: AttributeConverterTypeAdapter.java From lams with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("unchecked") public AttributeConverterTypeAdapter( String name, String description, JpaAttributeConverter<? extends T,?> attributeConverter, SqlTypeDescriptor sqlTypeDescriptorAdapter, Class modelType, Class jdbcType, JavaTypeDescriptor<T> entityAttributeJavaTypeDescriptor) { super( sqlTypeDescriptorAdapter, entityAttributeJavaTypeDescriptor ); this.name = name; this.description = description; this.modelType = modelType; this.jdbcType = jdbcType; this.attributeConverter = attributeConverter; this.mutabilityPlan = entityAttributeJavaTypeDescriptor.getMutabilityPlan().isMutable() ? new AttributeConverterMutabilityPlanImpl<T>( attributeConverter ) : ImmutableMutabilityPlan.INSTANCE; log.debug( "Created AttributeConverterTypeAdapter -> " + name ); }
Example #2
Source File: JpaAttributeConverterImpl.java From lams with GNU General Public License v2.0 | 5 votes |
public JpaAttributeConverterImpl( ManagedBean<AttributeConverter<O, R>> attributeConverterBean, JavaTypeDescriptor<AttributeConverter<O,R>> converterJavaTypeDescriptor, JavaTypeDescriptor<O> domainJavaTypeDescriptor, JavaTypeDescriptor<R> relationalJavaTypeDescriptor) { this.attributeConverterBean = attributeConverterBean; this.converterJavaTypeDescriptor = converterJavaTypeDescriptor; this.domainJavaTypeDescriptor = (BasicJavaDescriptor<O>) domainJavaTypeDescriptor; this.relationalJavaTypeDescriptor = (BasicJavaDescriptor<R>) relationalJavaTypeDescriptor; }
Example #3
Source File: AbstractHeuristicUserType.java From jadira with Apache License 2.0 | 5 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override @Deprecated public String toXMLString(Object object) { final JavaTypeDescriptor desc = type.getJavaTypeDescriptor(); return desc.toString(object); }
Example #4
Source File: JsonStringSqlTypeDescriptor.java From hibernate-types with Apache License 2.0 | 5 votes |
@Override public <X> ValueBinder<X> getBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) { return new BasicBinder<X>(javaTypeDescriptor, this) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { st.setString(index, javaTypeDescriptor.unwrap(value, String.class, options)); } }; }
Example #5
Source File: JsonBinarySqlTypeDescriptor.java From hibernate-types with Apache License 2.0 | 5 votes |
@Override public <X> ValueBinder<X> getBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) { return new BasicBinder<X>(javaTypeDescriptor, this) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { st.setObject(index, javaTypeDescriptor.unwrap(value, JsonNode.class, options), getSqlType()); } }; }
Example #6
Source File: AbstractJsonSqlTypeDescriptor.java From hibernate-types with Apache License 2.0 | 5 votes |
@Override public <X> ValueExtractor<X> getExtractor(final JavaTypeDescriptor<X> javaTypeDescriptor) { return new BasicExtractor<X>(javaTypeDescriptor, this) { @Override protected X doExtract(ResultSet rs, String name, WrapperOptions options) throws SQLException { return javaTypeDescriptor.wrap(extractJson(rs, name), options); } }; }
Example #7
Source File: ArraySqlTypeDescriptor.java From hibernate-types with Apache License 2.0 | 5 votes |
@Override public <X> ValueExtractor<X> getExtractor(final JavaTypeDescriptor<X> javaTypeDescriptor) { return new BasicExtractor<X>(javaTypeDescriptor, this) { @Override protected X doExtract(ResultSet rs, String name, WrapperOptions options) throws SQLException { return javaTypeDescriptor.wrap(rs.getArray(name), options); } }; }
Example #8
Source File: ArraySqlTypeDescriptor.java From hibernate-types with Apache License 2.0 | 5 votes |
@Override public <X> ValueBinder<X> getBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) { return new BasicBinder<X>(javaTypeDescriptor, this) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { AbstractArrayTypeDescriptor<Object> abstractArrayTypeDescriptor = (AbstractArrayTypeDescriptor<Object>) javaTypeDescriptor; st.setArray(index, st.getConnection().createArrayOf( abstractArrayTypeDescriptor.getSqlArrayType(), abstractArrayTypeDescriptor.unwrap(value, Object[].class, options) )); } }; }
Example #9
Source File: JsonStringSqlTypeDescriptor.java From hibernate-types with Apache License 2.0 | 5 votes |
@Override public <X> ValueBinder<X> getBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) { return new BasicBinder<X>(javaTypeDescriptor, this) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { st.setString(index, javaTypeDescriptor.unwrap(value, String.class, options)); } }; }
Example #10
Source File: JsonBinarySqlTypeDescriptor.java From hibernate-types with Apache License 2.0 | 5 votes |
@Override public <X> ValueBinder<X> getBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) { return new BasicBinder<X>(javaTypeDescriptor, this) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { st.setObject(index, javaTypeDescriptor.unwrap(value, JsonNode.class, options), getSqlType()); } }; }
Example #11
Source File: ArraySqlTypeDescriptor.java From hibernate-types with Apache License 2.0 | 5 votes |
@Override public <X> ValueBinder<X> getBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) { return new BasicBinder<X>(javaTypeDescriptor, this) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { AbstractArrayTypeDescriptor<Object> abstractArrayTypeDescriptor = (AbstractArrayTypeDescriptor<Object>) javaTypeDescriptor; st.setArray(index, st.getConnection().createArrayOf( abstractArrayTypeDescriptor.getSqlArrayType(), abstractArrayTypeDescriptor.unwrap(value, Object[].class, options) )); } }; }
Example #12
Source File: PostgreSQLEnumType.java From hibernate-types with Apache License 2.0 | 5 votes |
/** * Initialization constructor taking the {@link Class}. * * @param enumClass The enum type */ public PostgreSQLEnumType(Class<? extends Enum> enumClass) { this(); Class typeConfigurationClass = ReflectionUtils.getClassOrNull("org.hibernate.type.spi.TypeConfiguration"); if(typeConfigurationClass != null) { Object typeConfiguration = ReflectionUtils.newInstance(typeConfigurationClass); Class enumJavaTypeDescriptorClass = ReflectionUtils.getClassOrNull("org.hibernate.type.descriptor.java.EnumJavaTypeDescriptor"); Object enumJavaTypeDescriptor = ReflectionUtils.newInstance(enumJavaTypeDescriptorClass, new Object[] {enumClass}, new Class[]{enumClass.getClass()}); Object javaTypeDescriptorRegistry = ReflectionUtils.invokeGetter(typeConfiguration, "javaTypeDescriptorRegistry"); ReflectionUtils.invokeMethod( javaTypeDescriptorRegistry, ReflectionUtils.getMethod(javaTypeDescriptorRegistry, "addDescriptor", JavaTypeDescriptor.class), enumJavaTypeDescriptor ); ReflectionUtils.invokeSetter(this, "typeConfiguration", typeConfiguration); } Properties properties = new Properties(); properties.setProperty("enumClass", enumClass.getName()); properties.setProperty("useNamed", Boolean.TRUE.toString()); setParameterValues(properties); }
Example #13
Source File: IgniteGridTypeDescriptor.java From hibernate-ogm-ignite with GNU Lesser General Public License v2.1 | 5 votes |
@Override public <X> GridValueBinder<X> getBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) { return new BasicGridBinder<X>( javaTypeDescriptor, this ) { @Override protected void doBind(Tuple resultset, X value, String[] names, WrapperOptions options) { resultset.put( names[0], javaTypeDescriptor.unwrap( value, targetClass, options ) ); } }; }
Example #14
Source File: JavaTypeDescriptorRegistry.java From lams with GNU General Public License v2.0 | 5 votes |
public void addDescriptor(JavaTypeDescriptor descriptor) { JavaTypeDescriptor old = descriptorsByClass.put( descriptor.getJavaType(), descriptor ); if ( old != null ) { log.debugf( "JavaTypeDescriptorRegistry entry replaced : %s -> %s (was %s)", descriptor.getJavaType(), descriptor, old ); } }
Example #15
Source File: JavaTypeDescriptorRegistry.java From lams with GNU General Public License v2.0 | 5 votes |
public <T> JavaTypeDescriptor<T> getDescriptor(Class<T> javaType) { return RegistryHelper.INSTANCE.resolveDescriptor( descriptorsByClass, javaType, () -> { log.debugf( "Could not find matching scoped JavaTypeDescriptor for requested Java class [%s]; " + "falling back to static registry", javaType.getName() ); return org.hibernate.type.descriptor.java.JavaTypeDescriptorRegistry.INSTANCE.getDescriptor( javaType ); } ); }
Example #16
Source File: StandardBasicTypeTemplate.java From lams with GNU General Public License v2.0 | 5 votes |
public StandardBasicTypeTemplate( SqlTypeDescriptor sqlTypeDescriptor, JavaTypeDescriptor<J> javaTypeDescriptor, String... registrationKeys) { super( sqlTypeDescriptor, javaTypeDescriptor ); this.registrationKeys = registrationKeys; this.name = javaTypeDescriptor.getJavaType() == null ? "(map-mode)" : javaTypeDescriptor.getJavaType().getName() + " -> " + sqlTypeDescriptor.getSqlType(); }
Example #17
Source File: AttributeConverterSqlTypeDescriptorAdapter.java From lams with GNU General Public License v2.0 | 5 votes |
public AttributeConverterSqlTypeDescriptorAdapter( JpaAttributeConverter converter, SqlTypeDescriptor delegate, JavaTypeDescriptor intermediateJavaTypeDescriptor) { this.converter = converter; this.delegate = delegate; this.intermediateJavaTypeDescriptor = intermediateJavaTypeDescriptor; }
Example #18
Source File: RegistryHelper.java From lams with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("unchecked") public <J> JavaTypeDescriptor<J> resolveDescriptor( Map<Class,JavaTypeDescriptor> descriptorsByClass, Class<J> cls, Supplier<JavaTypeDescriptor<J>> defaultValueSupplier) { if ( cls == null ) { throw new IllegalArgumentException( "Class passed to locate JavaTypeDescriptor cannot be null" ); } JavaTypeDescriptor<J> descriptor = descriptorsByClass.get( cls ); if ( descriptor != null ) { return descriptor; } if ( cls.isEnum() ) { descriptor = new EnumJavaTypeDescriptor( cls ); descriptorsByClass.put( cls, descriptor ); return descriptor; } // find the first "assignable" match for ( Map.Entry<Class, JavaTypeDescriptor> entry : descriptorsByClass.entrySet() ) { if ( entry.getKey().isAssignableFrom( cls ) ) { log.debugf( "Using cached JavaTypeDescriptor instance for Java class [%s]", cls.getName() ); return entry.getValue(); } } return defaultValueSupplier.get(); }
Example #19
Source File: BasicExtractor.java From lams with GNU General Public License v2.0 | 4 votes |
public BasicExtractor(JavaTypeDescriptor<J> javaDescriptor, SqlTypeDescriptor sqlDescriptor) { this.javaDescriptor = javaDescriptor; this.sqlDescriptor = sqlDescriptor; }
Example #20
Source File: MetadataBuilderImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public void contributeJavaTypeDescriptor(JavaTypeDescriptor descriptor) { this.bootstrapContext.getTypeConfiguration().getJavaTypeDescriptorRegistry().addDescriptor( descriptor ); }
Example #21
Source File: AbstractSingleColumnStandardBasicType.java From lams with GNU General Public License v2.0 | 4 votes |
public AbstractSingleColumnStandardBasicType(SqlTypeDescriptor sqlTypeDescriptor, JavaTypeDescriptor<T> javaTypeDescriptor) { super( sqlTypeDescriptor, javaTypeDescriptor ); }
Example #22
Source File: AbstractStandardBasicType.java From lams with GNU General Public License v2.0 | 4 votes |
public AbstractStandardBasicType(SqlTypeDescriptor sqlTypeDescriptor, JavaTypeDescriptor<T> javaTypeDescriptor) { this.sqlTypeDescriptor = sqlTypeDescriptor; this.sqlTypes = new int[] { sqlTypeDescriptor.getSqlType() }; this.javaTypeDescriptor = javaTypeDescriptor; }
Example #23
Source File: JpaAttributeConverterImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public JavaTypeDescriptor<AttributeConverter<O, R>> getConverterJavaTypeDescriptor() { return converterJavaTypeDescriptor; }
Example #24
Source File: AbstractStandardBasicType.java From lams with GNU General Public License v2.0 | 4 votes |
public final JavaTypeDescriptor<T> getJavaTypeDescriptor() { return javaTypeDescriptor; }
Example #25
Source File: AbstractStandardBasicType.java From lams with GNU General Public License v2.0 | 4 votes |
public final void setJavaTypeDescriptor( JavaTypeDescriptor<T> javaTypeDescriptor ) { this.javaTypeDescriptor = javaTypeDescriptor; }
Example #26
Source File: ClobTypeDescriptor.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public <X> ValueBinder<X> getBinder(JavaTypeDescriptor<X> javaTypeDescriptor) { return getClobBinder( javaTypeDescriptor ); }
Example #27
Source File: IgniteGridTypeDescriptor.java From hibernate-ogm-ignite with GNU Lesser General Public License v2.1 | 4 votes |
@Override public <X> GridValueExtractor<X> getExtractor(JavaTypeDescriptor<X> javaTypeDescriptor) { return new BasicGridExtractor<X>( javaTypeDescriptor, true ); }
Example #28
Source File: AbstractHeuristicUserType.java From jadira with Apache License 2.0 | 4 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public String objectToSQLString(Object object) { final JavaTypeDescriptor desc = type.getJavaTypeDescriptor(); return desc.toString(object); }
Example #29
Source File: BasicBinder.java From lams with GNU General Public License v2.0 | 4 votes |
public BasicBinder(JavaTypeDescriptor<J> javaDescriptor, SqlTypeDescriptor sqlDescriptor) { this.javaDescriptor = javaDescriptor; this.sqlDescriptor = sqlDescriptor; }
Example #30
Source File: BasicBinder.java From lams with GNU General Public License v2.0 | 4 votes |
public JavaTypeDescriptor<J> getJavaDescriptor() { return javaDescriptor; }