test failures from custom-type work

This commit is contained in:
Steve Ebersole 2021-10-08 09:46:53 -05:00
parent 41603e8d75
commit fbba2d49a9
3 changed files with 26 additions and 3 deletions

View File

@ -28,6 +28,13 @@ public class UserTypeLegacyBridge extends BaseUserTypeSupport<Object> implements
private TypeConfiguration typeConfiguration;
private String hbmStyleTypeName;
public UserTypeLegacyBridge() {
}
public UserTypeLegacyBridge(String hbmStyleTypeName) {
this.hbmStyleTypeName = hbmStyleTypeName;
}
@Override
public TypeConfiguration getTypeConfiguration() {
return typeConfiguration;
@ -40,6 +47,11 @@ public class UserTypeLegacyBridge extends BaseUserTypeSupport<Object> implements
@Override
public void setParameterValues(Properties parameters) {
if ( hbmStyleTypeName != null ) {
// assume it was ctor-injected
return;
}
hbmStyleTypeName = parameters.getProperty( TYPE_NAME_PARAM_KEY );
if ( hbmStyleTypeName == null ) {
throw new MappingException( "Missing `@Parameter` for `" + TYPE_NAME_PARAM_KEY + "`" );

View File

@ -25,6 +25,8 @@ import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.testing.orm.junit.NotImplementedYet;
import org.junit.Ignore;
import org.junit.Test;
import jakarta.persistence.OptimisticLockException;
@ -39,8 +41,8 @@ import static org.junit.Assert.fail;
/**
* @author Emmanuel Bernard
*/
// todo (6.0): needs a composite user type mechanism e.g. by providing a custom ComponentTuplizer/Instantiator
//@Ignore( "Missing support for composite user types" )
@Ignore( "Missing support for composite user types" )
@NotImplementedYet( /* just so we can find this later via the annotation */ )
public class BasicHibernateAnnotationsTest extends BaseCoreFunctionalTestCase {
@Override
protected boolean isCleanupTestDataRequired() {

View File

@ -13,9 +13,11 @@ import java.util.List;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.CustomType;
import org.hibernate.annotations.JdbcTypeCode;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration;
import org.hibernate.usertype.UserTypeLegacyBridge;
import org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@ -95,7 +97,8 @@ public class LazyInCacheTest extends BaseCoreFunctionalTestCase {
List<Tag> tags = new ArrayList<>();
@Basic( fetch = FetchType.LAZY )
@JdbcTypeCode(Types.LONGVARBINARY)
@CustomType( BinaryCustomType.class )
// @JdbcTypeCode(Types.LONGVARBINARY)
byte[] data;
}
@ -120,4 +123,10 @@ public class LazyInCacheTest extends BaseCoreFunctionalTestCase {
String name;
}
public static class BinaryCustomType extends UserTypeLegacyBridge {
public BinaryCustomType() {
super( "binary" );
}
}
}