Replacement for org.hibernate.transform.BasicTransformerAdapter removed in 6.0?

Hi,

I have some legacy code that we updated from Hibernate 3.6 to 5.6 and now in a second step I would like to update to 6.1. In 6.1, the class org.hibernate.transform.BasicTransformerAdapter was removed. Is there a replacement for that class? I could not find any replacements in the API.

We use it as an extension class for a custom result transformer:

import org.hibernate.transform.BasicTransformerAdapter;

public class AliasToEntityOrderedMapResultTransformer extends BasicTransformerAdapter implements Serializable {
	
	private static final long serialVersionUID = 1921699653066238291L;
	
	public static final AliasToEntityOrderedMapResultTransformer INSTANCE = new AliasToEntityOrderedMapResultTransformer();

	private AliasToEntityOrderedMapResultTransformer () {
	
	}

	@SuppressWarnings({ "rawtypes", "unchecked" })
	public Object transformTuple(Object[] tuple, String[] aliases) {	           
	    Map result = new LinkedHashMap(tuple.length);
	    
	    for (int i=0; i<tuple.length; i++) {
	        String alias = aliases[i];
	        if ( alias != null ) {
	            result.put(alias, tuple[i]);
	        }
	    }
	    
	    return result;
	}

	public boolean isTransformedValueATupleElement(String[] aliases, int tupleLength) {
	    return false;
	}

	private Object readResolve() {
	    return INSTANCE;
	}
}

BasicTransformerAdapter is just a no-op base implementation. Just implement the org.hibernate.transform.ResultTransformer interface instead.

1 Like