public AdaptedImmutableType(AbstractStandardBasicType<T> baseMutableType) { super( baseMutableType.getSqlTypeDescriptor(), baseMutableType.getJavaTypeDescriptor() ); this.baseMutableType = baseMutableType; }
private void dump(PersistentClass entityBinding, TheEntity theEntity) { final Iterator propertyBindingIterator = entityBinding.getPropertyClosureIterator(); while ( propertyBindingIterator.hasNext() ) { final Property propertyBinding = (Property) propertyBindingIterator.next(); final JavaTypeDescriptor javaTypeDescriptor = ( (AbstractStandardBasicType) propertyBinding.getType() ).getJavaTypeDescriptor(); System.out.println( String.format( "%s (%s) -> %s", propertyBinding.getName(), javaTypeDescriptor.getJavaType().getSimpleName(), javaTypeDescriptor.toString( propertyBinding.getGetter( TheEntity.class ).get( theEntity ) ) ) ); } }
assertTyping( EnumJavaTypeDescriptor.class, basicType.getJavaTypeDescriptor() ); assertEquals( Types.VARCHAR, basicType.getSqlTypeDescriptor().getSqlType() );
@Test public void testBasicOperation() { SimpleValue simpleValue = new SimpleValue( new MetadataBuildingContextTestingImpl() ); simpleValue.setJpaAttributeConverterDescriptor( new InstanceBasedConverterDescriptor( new StringClobConverter(), new ClassmateContext() ) ); simpleValue.setTypeUsingReflection( IrrelevantEntity.class.getName(), "name" ); Type type = simpleValue.getType(); assertNotNull( type ); if ( !AttributeConverterTypeAdapter.class.isInstance( type ) ) { fail( "AttributeConverter not applied" ); } AbstractStandardBasicType basicType = assertTyping( AbstractStandardBasicType.class, type ); assertSame( StringTypeDescriptor.INSTANCE, basicType.getJavaTypeDescriptor() ); assertEquals( Types.CLOB, basicType.getSqlTypeDescriptor().getSqlType() ); }
@Test public void testBasicConverterApplication() { final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build(); try { MetadataImplementor metadata = (MetadataImplementor) new MetadataSources( ssr ) .addAnnotatedClass( Tester.class ) .getMetadataBuilder() .applyAttributeConverter( StringClobConverter.class, true ) .build(); PersistentClass tester = metadata.getEntityBinding( Tester.class.getName() ); Property nameProp = tester.getProperty( "name" ); SimpleValue nameValue = (SimpleValue) nameProp.getValue(); Type type = nameValue.getType(); assertNotNull( type ); assertTyping( BasicType.class, type ); if ( !AttributeConverterTypeAdapter.class.isInstance( type ) ) { fail( "AttributeConverter not applied" ); } AbstractStandardBasicType basicType = assertTyping( AbstractStandardBasicType.class, type ); assertSame( StringTypeDescriptor.INSTANCE, basicType.getJavaTypeDescriptor() ); assertEquals( Types.CLOB, basicType.getSqlTypeDescriptor().getSqlType() ); } finally { StandardServiceRegistryBuilder.destroy( ssr ); } }
@Test public void testBasicConverterDisableApplication() { final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build(); try { MetadataImplementor metadata = (MetadataImplementor) new MetadataSources( ssr ) .addAnnotatedClass( Tester2.class ) .getMetadataBuilder() .applyAttributeConverter( StringClobConverter.class, true ) .build(); PersistentClass tester = metadata.getEntityBinding( Tester2.class.getName() ); Property nameProp = tester.getProperty( "name" ); SimpleValue nameValue = (SimpleValue) nameProp.getValue(); Type type = nameValue.getType(); assertNotNull( type ); if ( AttributeConverterTypeAdapter.class.isInstance( type ) ) { fail( "AttributeConverter applied (should not have been)" ); } AbstractStandardBasicType basicType = assertTyping( AbstractStandardBasicType.class, type ); assertSame( StringTypeDescriptor.INSTANCE, basicType.getJavaTypeDescriptor() ); assertEquals( Types.VARCHAR, basicType.getSqlTypeDescriptor().getSqlType() ); } finally { StandardServiceRegistryBuilder.destroy( ssr ); } }
public AdaptedImmutableType(AbstractStandardBasicType<T> baseMutableType) { super( baseMutableType.getSqlTypeDescriptor(), baseMutableType.getJavaTypeDescriptor() ); this.baseMutableType = baseMutableType; }
public AdaptedImmutableType(AbstractStandardBasicType<T> baseMutableType) { super( baseMutableType.getSqlTypeDescriptor(), baseMutableType.getJavaTypeDescriptor() ); this.baseMutableType = baseMutableType; }
@SuppressWarnings({ "unchecked", "rawtypes" }) static void replaceJavaTypeDescriptor(AbstractStandardBasicType<?> abstractStandardBasicType) { JavaTypeDescriptor<?> javaTypeDescriptor = abstractStandardBasicType.getJavaTypeDescriptor(); if (javaTypeDescriptor != null && !(javaTypeDescriptor instanceof WrapperJavaTypeDescriptor)) { abstractStandardBasicType.setJavaTypeDescriptor((JavaTypeDescriptor)new WrapperJavaTypeDescriptor(javaTypeDescriptor)); } }