get rid of warnings in JdbcTypeJavaClassMappings
This commit is contained in:
parent
ae8b3f9a33
commit
7a75a0734b
|
@ -39,20 +39,20 @@ import org.jboss.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maintains the JDBC recommended mappings for JDBC type-code to/from Java Class
|
* Maintains the JDBC recommended mappings for JDBC type-code to/from Java Class
|
||||||
* as defined in _Appendix B : Data Type Conversion Tables_ of the _JDBC 4.0 Specification_
|
* as defined in <em>Appendix B: Data Type Conversion Tables</em> of the JDBC
|
||||||
*
|
* Specification.
|
||||||
* Eventually, the plan is to have {@link org.hibernate.dialect.Dialect} and
|
|
||||||
* {@link java.sql.DatabaseMetaData#getTypeInfo()} contribute this information.
|
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
|
//TODO: Eventually, the plan is to have {@link org.hibernate.dialect.Dialect} and
|
||||||
|
// {@link java.sql.DatabaseMetaData#getTypeInfo()} contribute this information.
|
||||||
public class JdbcTypeJavaClassMappings {
|
public class JdbcTypeJavaClassMappings {
|
||||||
private static final Logger log = Logger.getLogger( JdbcTypeJavaClassMappings.class );
|
private static final Logger log = Logger.getLogger( JdbcTypeJavaClassMappings.class );
|
||||||
|
|
||||||
public static final JdbcTypeJavaClassMappings INSTANCE = new JdbcTypeJavaClassMappings();
|
public static final JdbcTypeJavaClassMappings INSTANCE = new JdbcTypeJavaClassMappings();
|
||||||
|
|
||||||
private final ConcurrentHashMap<Class, Integer> javaClassToJdbcTypeCodeMap;
|
private final ConcurrentHashMap<Class<?>, Integer> javaClassToJdbcTypeCodeMap;
|
||||||
private final ConcurrentHashMap<Integer, Class> jdbcTypeCodeToJavaClassMap;
|
private final ConcurrentHashMap<Integer, Class<?>> jdbcTypeCodeToJavaClassMap;
|
||||||
|
|
||||||
private JdbcTypeJavaClassMappings() {
|
private JdbcTypeJavaClassMappings() {
|
||||||
javaClassToJdbcTypeCodeMap = buildJavaClassToJdbcTypeCodeMappings();
|
javaClassToJdbcTypeCodeMap = buildJavaClassToJdbcTypeCodeMappings();
|
||||||
|
@ -61,12 +61,12 @@ public class JdbcTypeJavaClassMappings {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For the given Java type, determine the JDBC recommended JDBC type.
|
* For the given Java type, determine the JDBC recommended JDBC type.
|
||||||
*
|
* <p>
|
||||||
* This includes the mappings defined in <i>TABLE B-2 - Java Types Mapped to JDBC Types</i>
|
* This includes the mappings defined in <em>TABLE B-2: Java Types Mapped to JDBC Types</em>
|
||||||
* as well as some additional "common sense" mappings for things like BigDecimal, BigInteger,
|
* and <em>TABLE B-4: Java Object Types Mapped to JDBC Types</em>, as well as some additional
|
||||||
* etc.
|
* "common sense" mappings.
|
||||||
*/
|
*/
|
||||||
public int determineJdbcTypeCodeForJavaClass(Class cls) {
|
public int determineJdbcTypeCodeForJavaClass(Class<?> cls) {
|
||||||
Integer typeCode = javaClassToJdbcTypeCodeMap.get( cls );
|
Integer typeCode = javaClassToJdbcTypeCodeMap.get( cls );
|
||||||
if ( typeCode != null ) {
|
if ( typeCode != null ) {
|
||||||
return typeCode;
|
return typeCode;
|
||||||
|
@ -80,11 +80,12 @@ public class JdbcTypeJavaClassMappings {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For the given JDBC type, determine the JDBC recommended Java type. These mappings
|
* For the given JDBC type, determine the JDBC recommended Java type.
|
||||||
* are defined by <i>TABLE B-1 - JDBC Types Mapped to Java Types</i>
|
* <p>
|
||||||
|
* These mappings are defined by <em>TABLE B-1: JDBC Types Mapped to Java Types</em>.
|
||||||
*/
|
*/
|
||||||
public Class determineJavaClassForJdbcTypeCode(Integer typeCode) {
|
public Class<?> determineJavaClassForJdbcTypeCode(Integer typeCode) {
|
||||||
Class cls = jdbcTypeCodeToJavaClassMap.get( typeCode );
|
Class<?> cls = jdbcTypeCodeToJavaClassMap.get( typeCode );
|
||||||
if ( cls != null ) {
|
if ( cls != null ) {
|
||||||
return cls;
|
return cls;
|
||||||
}
|
}
|
||||||
|
@ -99,15 +100,15 @@ public class JdbcTypeJavaClassMappings {
|
||||||
/**
|
/**
|
||||||
* @see #determineJavaClassForJdbcTypeCode(Integer)
|
* @see #determineJavaClassForJdbcTypeCode(Integer)
|
||||||
*/
|
*/
|
||||||
public Class determineJavaClassForJdbcTypeCode(int typeCode) {
|
public Class<?> determineJavaClassForJdbcTypeCode(int typeCode) {
|
||||||
return determineJavaClassForJdbcTypeCode( Integer.valueOf( typeCode ) );
|
return determineJavaClassForJdbcTypeCode( Integer.valueOf( typeCode ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
private static ConcurrentHashMap<Class, Integer> buildJavaClassToJdbcTypeCodeMappings() {
|
private static ConcurrentHashMap<Class<?>, Integer> buildJavaClassToJdbcTypeCodeMappings() {
|
||||||
final ConcurrentHashMap<Class, Integer> workMap = new ConcurrentHashMap<>();
|
final ConcurrentHashMap<Class<?>, Integer> workMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
// these mappings are the ones outlined specifically in the spec
|
// these mappings are the ones outlined specifically in the spec
|
||||||
workMap.put( String.class, SqlTypes.VARCHAR );
|
workMap.put( String.class, SqlTypes.VARCHAR );
|
||||||
|
@ -157,8 +158,8 @@ public class JdbcTypeJavaClassMappings {
|
||||||
return workMap;
|
return workMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ConcurrentHashMap<Integer, Class> buildJdbcTypeCodeToJavaClassMappings() {
|
private static ConcurrentHashMap<Integer, Class<?>> buildJdbcTypeCodeToJavaClassMappings() {
|
||||||
final ConcurrentHashMap<Integer, Class> workMap = new ConcurrentHashMap<>();
|
final ConcurrentHashMap<Integer, Class<?>> workMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
workMap.put( SqlTypes.CHAR, String.class );
|
workMap.put( SqlTypes.CHAR, String.class );
|
||||||
workMap.put( SqlTypes.VARCHAR, String.class );
|
workMap.put( SqlTypes.VARCHAR, String.class );
|
||||||
|
|
Loading…
Reference in New Issue