Skip to content

Commit

Permalink
HHH-8816 - Unable to instantiate AttributeConverter: root cause of ex…
Browse files Browse the repository at this point in the history
…ception hidden
  • Loading branch information
sebersole committed Mar 20, 2014
1 parent fc57772 commit d023c7c
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java
Expand Up @@ -2629,16 +2629,24 @@ public void setCurrentTenantIdentifierResolver(CurrentTenantIdentifierResolver c
* by its "entity attribute" parameterized type?
*/
public void addAttributeConverter(Class<? extends AttributeConverter> attributeConverterClass, boolean autoApply) {
final AttributeConverter attributeConverter;
addAttributeConverter(
instantiateAttributeConverter( attributeConverterClass ),
autoApply
);
}

private AttributeConverter instantiateAttributeConverter(Class<? extends AttributeConverter> attributeConverterClass) {
AttributeConverter attributeConverter;
try {
attributeConverter = attributeConverterClass.newInstance();
}
catch (Exception e) {
throw new AnnotationException(
"Unable to instantiate AttributeConverter [" + attributeConverterClass.getName() + "]"
"Unable to instantiate AttributeConverter [" + attributeConverterClass.getName() + "]",
e
);
}
addAttributeConverter( attributeConverter, autoApply );
return attributeConverter;
}

/**
Expand All @@ -2647,17 +2655,7 @@ public void addAttributeConverter(Class<? extends AttributeConverter> attributeC
* @param attributeConverterClass The AttributeConverter class.
*/
public void addAttributeConverter(Class<? extends AttributeConverter> attributeConverterClass) {
final AttributeConverter attributeConverter;
try {
attributeConverter = attributeConverterClass.newInstance();
}
catch (Exception e) {
throw new AnnotationException(
"Unable to instantiate AttributeConverter [" + attributeConverterClass.getName() + "]"
);
}

addAttributeConverter( attributeConverter );
addAttributeConverter( instantiateAttributeConverter( attributeConverterClass ) );
}

/**
Expand Down

0 comments on commit d023c7c

Please sign in to comment.