Skip to content

Commit

Permalink
HHH-2614 Blob Length Set to 255 By Default With Derby DB
Browse files Browse the repository at this point in the history
  • Loading branch information
stliu committed Jul 11, 2011
1 parent 5588f23 commit a2bae5a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
Expand Up @@ -24,6 +24,7 @@
package org.hibernate.dialect;

import java.lang.reflect.Method;
import java.sql.Types;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -53,7 +54,11 @@ public DerbyDialect() {
super();
registerFunction( "concat", new DerbyConcatFunction() );
registerFunction( "trim", new AnsiTrimFunction() );
registerColumnType( Types.BLOB, "blob" );
determineDriverVersion();
if ( driverVersionMajor > 10 || ( driverVersionMajor == 10 && driverVersionMinor >= 7 ) ) {
registerColumnType( Types.BOOLEAN, "boolean" );
}
}

@SuppressWarnings({ "UnnecessaryUnboxing" })
Expand Down
24 changes: 12 additions & 12 deletions hibernate-core/src/main/java/org/hibernate/dialect/TypeNames.java
Expand Up @@ -87,18 +87,18 @@ public String get(int typecode) throws MappingException {
* @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 );
if ( map!=null && map.size()>0 ) {
// iterate entries ordered by capacity to find first fit
for (Map.Entry<Integer, String> entry: map.entrySet()) {
if ( size <= ( entry.getKey() ).intValue() ) {
return replace( entry.getValue(), size, precision, scale );
}
}
}
return replace( get(typecode), size, precision, scale );
}
public String get(int typecode, int size, int precision, int scale) throws MappingException {
Map<Integer, 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() ) {
if ( size <= entry.getKey() ) {
return replace( entry.getValue(), size, precision, scale );
}
}
}
return replace( get( typecode ), size, precision, scale );
}

private static String replace(String type, int size, int precision, int scale) {
type = StringHelper.replaceOnce(type, "$s", Integer.toString(scale) );
Expand Down
Expand Up @@ -45,6 +45,7 @@
import org.hibernate.type.descriptor.java.MutabilityPlan;
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
import org.hibernate.util.ArrayHelper;
import org.hibernate.util.StringHelper;

/**
* TODO : javadoc
Expand Down Expand Up @@ -79,7 +80,7 @@ public String toXMLString(T value, SessionFactoryImplementor factory) throws Hib
}

public T fromXMLString(String xml, Mapping factory) throws HibernateException {
return xml == null || xml.length() == 0 ? null : fromStringValue( xml );
return StringHelper.isEmpty( xml ) ? null : fromStringValue( xml );
}

protected MutabilityPlan<T> getMutabilityPlan() {
Expand Down

0 comments on commit a2bae5a

Please sign in to comment.