HHH-13495 Do not use BoundedConcurrentHashMap for NationalizedTypeMappings
This commit is contained in:
parent
3088a2cfd0
commit
ab832caf0d
|
@ -9,10 +9,6 @@ package org.hibernate.type.descriptor.sql;
|
||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.hibernate.internal.util.collections.BoundedConcurrentHashMap;
|
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages a mapping between nationalized and non-nationalized variants of JDBC types.
|
* Manages a mapping between nationalized and non-nationalized variants of JDBC types.
|
||||||
*
|
*
|
||||||
|
@ -22,33 +18,23 @@ import org.jboss.logging.Logger;
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class NationalizedTypeMappings {
|
public class NationalizedTypeMappings {
|
||||||
private static final Logger log = Logger.getLogger( NationalizedTypeMappings.class );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Singleton access
|
* Singleton access
|
||||||
*/
|
*/
|
||||||
public static final NationalizedTypeMappings INSTANCE = new NationalizedTypeMappings();
|
public static final NationalizedTypeMappings INSTANCE = new NationalizedTypeMappings();
|
||||||
|
|
||||||
private final Map<Integer,Integer> nationalizedCodeByNonNationalized;
|
private NationalizedTypeMappings() {
|
||||||
|
|
||||||
public NationalizedTypeMappings() {
|
|
||||||
this.nationalizedCodeByNonNationalized = new BoundedConcurrentHashMap<Integer, Integer>();
|
|
||||||
map( Types.CHAR, Types.NCHAR );
|
|
||||||
map( Types.CLOB, Types.NCLOB );
|
|
||||||
map( Types.LONGVARCHAR, Types.LONGNVARCHAR );
|
|
||||||
map( Types.VARCHAR, Types.NVARCHAR );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void map(int nonNationalizedCode, int nationalizedCode) {
|
|
||||||
nationalizedCodeByNonNationalized.put( nonNationalizedCode, nationalizedCode );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCorrespondingNationalizedCode(int jdbcCode) {
|
public int getCorrespondingNationalizedCode(int jdbcCode) {
|
||||||
Integer nationalizedCode = nationalizedCodeByNonNationalized.get( jdbcCode );
|
switch ( jdbcCode ) {
|
||||||
if ( nationalizedCode == null ) {
|
case Types.CHAR: return Types.NCHAR;
|
||||||
log.debug( "Unable to locate nationalized jdbc-code equivalent for given jdbc code : " + jdbcCode );
|
case Types.CLOB: return Types.NCLOB;
|
||||||
return jdbcCode;
|
case Types.LONGVARCHAR: return Types.LONGNVARCHAR;
|
||||||
|
case Types.VARCHAR: return Types.NVARCHAR;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException( "Unable to locate nationalized jdbc-code equivalent for given jdbc code : " + jdbcCode );
|
||||||
}
|
}
|
||||||
return nationalizedCode;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue