HHH-6450 : Change length argument of Dialect.getTypeName() and TypeNames size/capacity to long

This commit is contained in:
Gail Badner 2011-07-15 17:53:05 -07:00
parent 809540b08c
commit b17e062a37
2 changed files with 12 additions and 12 deletions

View File

@ -286,7 +286,7 @@ public abstract class Dialect {
* @return the database type name
* @throws HibernateException If no mapping was specified for that type.
*/
public String getTypeName(int code, int length, int precision, int scale) throws HibernateException {
public String getTypeName(int code, long length, int precision, int scale) throws HibernateException {
String result = typeNames.get( code, length, precision, scale );
if ( result == null ) {
throw new HibernateException(
@ -319,7 +319,7 @@ public abstract class Dialect {
* @param capacity The maximum length of database type
* @param name The database type name
*/
protected void registerColumnType(int code, int capacity, String name) {
protected void registerColumnType(int code, long capacity, String name) {
typeNames.put( code, capacity, name );
}
@ -580,7 +580,7 @@ public abstract class Dialect {
* @param capacity The maximum length of database type
* @param name The Hibernate {@link org.hibernate.type.Type} name
*/
protected void registerHibernateType(int code, int capacity, String name) {
protected void registerHibernateType(int code, long capacity, String name) {
hibernateTypeNames.put( code, capacity, name);
}

View File

@ -62,7 +62,7 @@ import org.hibernate.internal.util.StringHelper;
*/
public class TypeNames {
private Map<Integer, Map<Integer, String>> weighted = new HashMap<Integer, Map<Integer, String>>();
private Map<Integer, Map<Long, String>> weighted = new HashMap<Integer, Map<Long, String>>();
private Map<Integer, String> defaults = new HashMap<Integer, String>();
/**
@ -85,11 +85,11 @@ public class TypeNames {
* @return the associated name with smallest capacity >= size,
* if available and the default type name otherwise
*/
public String get(int typecode, int size, int precision, int scale) throws MappingException {
Map<Integer, String> map = weighted.get( typecode );
public String get(int typecode, long size, int precision, int scale) throws MappingException {
Map<Long, String> map = weighted.get( typecode );
if ( map!=null && map.size()>0 ) {
// iterate entries ordered by capacity to find first fit
for (Map.Entry<Integer, String> entry: map.entrySet()) {
for (Map.Entry<Long, String> entry: map.entrySet()) {
if ( size <= entry.getKey() ) {
return replace( entry.getValue(), size, precision, scale );
}
@ -98,9 +98,9 @@ public class TypeNames {
return replace( get(typecode), size, precision, scale );
}
private static String replace(String type, int size, int precision, int scale) {
private static String replace(String type, long size, int precision, int scale) {
type = StringHelper.replaceOnce(type, "$s", Integer.toString(scale) );
type = StringHelper.replaceOnce(type, "$l", Integer.toString(size) );
type = StringHelper.replaceOnce(type, "$l", Long.toString(size) );
return StringHelper.replaceOnce(type, "$p", Integer.toString(precision) );
}
@ -108,10 +108,10 @@ public class TypeNames {
* set a type name for specified type key and capacity
* @param typecode the type key
*/
public void put(int typecode, int capacity, String value) {
Map<Integer, String> map = weighted.get( typecode );
public void put(int typecode, long capacity, String value) {
Map<Long, String> map = weighted.get( typecode );
if (map == null) {// add new ordered map
map = new TreeMap<Integer, String>();
map = new TreeMap<Long, String>();
weighted.put( typecode, map );
}
map.put(capacity, value);