/** * Adds the AttributeConverter instance to this Configuration. This form is mainly intended for developers * to programmatically add their own AttributeConverter instance. HEM, instead, uses the * {@link #addAttributeConverter(Class, boolean)} form * * @param attributeConverter The AttributeConverter instance. */ public void addAttributeConverter(AttributeConverter attributeConverter) { addAttributeConverter( AttributeConverterDefinition.from( attributeConverter ) ); }
/** * Adds the AttributeConverter Class to this Configuration. * * @param attributeConverterClass The AttributeConverter class. */ public void addAttributeConverter(Class<? extends AttributeConverter> attributeConverterClass) { addAttributeConverter( AttributeConverterDefinition.from( attributeConverterClass ) ); }
/** * Adds the AttributeConverter instance to this Configuration. This form is mainly intended for developers * to programmatically add their own AttributeConverter instance. HEM, instead, uses the * {@link #addAttributeConverter(Class, boolean)} form * * @param attributeConverter The AttributeConverter instance. * @param autoApply Should the AttributeConverter be auto applied to property types as specified * by its "entity attribute" parameterized type? */ public void addAttributeConverter(AttributeConverter attributeConverter, boolean autoApply) { addAttributeConverter( AttributeConverterDefinition.from( attributeConverter, autoApply ) ); }
/** * Adds the AttributeConverter Class to this Configuration. * * @param attributeConverterClass The AttributeConverter class. * @param autoApply Should the AttributeConverter be auto applied to property types as specified * by its "entity attribute" parameterized type? */ public void addAttributeConverter(Class<? extends AttributeConverter> attributeConverterClass, boolean autoApply) { addAttributeConverter( AttributeConverterDefinition.from( attributeConverterClass, autoApply ) ); }
@Test public void testBasicTimestampUsage() { Configuration cfg = new Configuration(); cfg.addAttributeConverter( InstantConverter.class, false ); cfg.addAnnotatedClass( IrrelevantInstantEntity.class ); cfg.setProperty( AvailableSettings.HBM2DDL_AUTO, "create-drop" );
@Test public void testBasicUsage() { Configuration cfg = new Configuration(); cfg.addAttributeConverter( IntegerToVarcharConverter.class, false ); cfg.addAnnotatedClass( Tester4.class ); cfg.setProperty( AvailableSettings.HBM2DDL_AUTO, "create-drop" );
@Test public void testErrorInstantiatingConverterClass() { Configuration cfg = new Configuration(); try { cfg.addAttributeConverter( BlowsUpConverter.class ); fail( "expecting an exception" ); } catch (AnnotationException e) { assertTyping( BlewUpException.class, ExceptionUtil.rootCause( e ) ); } }
@Test public void testChangeImmutableAttribute(){ configuration().addAttributeConverter( ExifConverter.class); configuration().addAttributeConverter( CaptionConverter.class);
@Test public void testImmutableAttribute(){ configuration().addAttributeConverter( ExifConverter.class); configuration().addAttributeConverter( CaptionConverter.class); Session s = openSession(); Transaction tx = s.beginTransaction();
@SuppressWarnings("unchecked") public static void registerConverter(Configuration config, Class<?> converterClass) { config.addAttributeConverter((Class<? extends AttributeConverter<?, ?>>) converterClass); } }
/** * Adds the AttributeConverter instance to this Configuration. This form is mainly intended for developers * to programmatically add their own AttributeConverter instance. HEM, instead, uses the * {@link #addAttributeConverter(Class, boolean)} form * * @param attributeConverter The AttributeConverter instance. */ public void addAttributeConverter(AttributeConverter attributeConverter) { addAttributeConverter( new InstanceBasedConverterDescriptor( attributeConverter, classmateContext ) ); }
/** * Adds the AttributeConverter instance to this Configuration. This form is mainly intended for developers * to programmatically add their own AttributeConverter instance. HEM, instead, uses the * {@link #addAttributeConverter(Class, boolean)} form * * @param attributeConverter The AttributeConverter instance. * @param autoApply Should the AttributeConverter be auto applied to property types as specified * by its "entity attribute" parameterized type? */ public void addAttributeConverter(AttributeConverter attributeConverter, boolean autoApply) { addAttributeConverter( new InstanceBasedConverterDescriptor( attributeConverter, autoApply, classmateContext ) ); }
/** * Adds the AttributeConverter Class to this Configuration. * * @param converterClass The AttributeConverter class. */ public <O,R> void addAttributeConverter(Class<? extends AttributeConverter<O,R>> converterClass) { addAttributeConverter( new ClassBasedConverterDescriptor( converterClass, classmateContext ) ); }
/** * Adds the AttributeConverter Class to this Configuration. * * @param converterClass The AttributeConverter class. * @param autoApply Should the AttributeConverter be auto applied to property types as specified * by its "entity attribute" parameterized type? */ public <O,R> void addAttributeConverter(Class<? extends AttributeConverter<O,R>> converterClass, boolean autoApply) { addAttributeConverter( new ClassBasedConverterDescriptor( converterClass, autoApply, classmateContext ) ); }