/** * 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 ) ); }
/** * 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 ) ); }
/** * Build an AttributeConverterDefinition from the AttributeConverter Class reference. The * converter is searched for a {@link Converter} annotation to determine whether it should * be treated as auto-apply. If the annotation is present, {@link Converter#autoApply()} is * used to make that determination. If the annotation is not present, {@code false} is assumed. * * @param attributeConverterClass The converter class * * @return The constructed definition */ public static AttributeConverterDefinition from(Class<? extends AttributeConverter> attributeConverterClass) { return from( instantiateAttributeConverter( attributeConverterClass ) ); }
/** * 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 ) ); }
private static class JpaEntityNotFoundDelegate implements EntityNotFoundDelegate, Serializable { /** * Singleton access */ public static final JpaEntityNotFoundDelegate INSTANCE = new JpaEntityNotFoundDelegate(); public void handleEntityNotFound(String entityName, Serializable id) { throw new EntityNotFoundException( "Unable to find " + entityName + " with id " + id ); } }
@Test public void testAttributeConverterOnSuperclass() { AttributeConverterDefinition def = AttributeConverterDefinition.from( StringIntegerConverterSubclass.class ); assertEquals( String.class, def.getEntityAttributeType() ); }
@Test public void testAttributeConverterOnInterface() { AttributeConverterDefinition def = AttributeConverterDefinition.from( StringLongAttributeConverterImpl.class ); assertEquals( String.class, def.getEntityAttributeType() ); }
@Test public void testParameterizedTypeWithTypeVariableAttributeConverterTypeArguments() { AttributeConverterDefinition def = AttributeConverterDefinition.from( StringListNoopAttributeConverter.class ); assertEquals( List.class, def.getEntityAttributeType() ); }
@Test public void testTypeVariableAttributeConverterTypeArguments() { AttributeConverterDefinition def = AttributeConverterDefinition.from( StringNoopAttributeConverter.class ); assertEquals( String.class, def.getEntityAttributeType() ); }
@Test @TestForIssue(jiraKey = "HHH-8804") public void testGenericTypeParameters() { AttributeConverterDefinition def = AttributeConverterDefinition.from( CustomAttributeConverter.class ); assertEquals( List.class, def.getEntityAttributeType() ); }
AttributeConverterDefinition.from( classLoaderService.<AttributeConverter>classForName( classDescriptor.getName() )