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 d023c7c commit 156bebd
Showing 1 changed file with 33 additions and 0 deletions.
Expand Up @@ -39,6 +39,7 @@
import javax.persistence.Entity;
import javax.persistence.Id;

import org.hibernate.AnnotationException;
import org.hibernate.IrrelevantEntity;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
Expand All @@ -65,6 +66,38 @@
* @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();
Expand Down

0 comments on commit 156bebd

Please sign in to comment.