HHH-8816 - Unable to instantiate AttributeConverter: root cause of exception hidden

This commit is contained in:
Steve Ebersole 2014-03-20 09:47:54 -05:00
parent d023c7c95c
commit 156bebd8a1
1 changed files with 33 additions and 0 deletions

View File

@ -39,6 +39,7 @@ import javax.persistence.Converter;
import javax.persistence.Entity;
import javax.persistence.Id;
import org.hibernate.AnnotationException;
import org.hibernate.IrrelevantEntity;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
@ -65,6 +66,38 @@ import org.junit.Test;
* @author Steve Ebersole
*/
public class AttributeConverterTest extends BaseUnitTestCase {
@Test
public void testErrorInstantiatingConverterClass() {
Configuration cfg = new Configuration();
try {
cfg.addAttributeConverter( BlowsUpConverter.class );
fail( "expecting an exception" );
}
catch (AnnotationException e) {
assertNotNull( e.getCause() );
assertTyping( BlewUpException.class, e.getCause() );
}
}
public static class BlewUpException extends RuntimeException {
}
public static class BlowsUpConverter implements AttributeConverter<String,String> {
public BlowsUpConverter() {
throw new BlewUpException();
}
@Override
public String convertToDatabaseColumn(String attribute) {
return null;
}
@Override
public String convertToEntityAttribute(String dbData) {
return null;
}
}
@Test
public void testBasicOperation() {
Configuration cfg = new Configuration();