Problem with conversion/mapping of char/varchar types.

Description

I'm working on an Database Synchronization tool and my problem is, when i have a char/varchar column type and it's field is empty on a select statement the method CharacterTypeDescriptor.wrap(X value, WrapperOptions options) throws a StringIndexOutOfBoundsException. By the way, looking at the implementation of method:
"...
if ( String.class.isInstance( value ) ) {
final String str = (String) value;
return Character.valueOf( str.charAt(0) );
..."

I can realize that the problem is on the "str.charAt(0)", my field(s) doesn't have any information, is empty and the system is a legacy system, I cannot modify that information. About the implementation of "wrap" it cannot be done this way:

"...
if ( String.class.isInstance( value ) ) {
final String str = (String) value;
if(str.length() == 0) {
return null
} else {
return Character.valueOf( str.charAt(0) );
}
..."
??
Any solution that I can do?

Activity

Brett MeyerOctober 11, 2013 at 4:02 PM

Gustavo, thanks much for the response!

Gustavo ViníciusOctober 11, 2013 at 2:16 PM

I realized that doesn't make any sense having an Varchar/Char field with default value "" and that isn't an problem that Hibernate should resolve. Even if it's a legacy database.

Gustavo ViníciusOctober 11, 2013 at 2:15 PM

I'm not working on that place anymore. But I have implemented the UserType interface as a 'workaround' to this 'problem'. I realized that doesn't make any sense having an Varchar/Char field with default value "" and that isn't an problem that Hibernate should resolve. Even if it's a legacy database.

Brett MeyerOctober 9, 2013 at 12:54 AM

I realize this was a year ago, but did you have any specific entities/mappings that were causing this?

Won't Fix

Details

Assignee

Reporter

Labels

Original estimate

Time tracking

No time logged56h remaining

Components

Affects versions

Priority

Created August 6, 2012 at 4:55 PM
Updated October 11, 2013 at 4:02 PM
Resolved October 11, 2013 at 2:16 PM

Flag notifications