Search code examples
databasejsongrailscharlegacy

Grails nullable column returns value = {"class":"java.lang.Character"} in JSON


I have a legacy database that I connect to and not sure why I get this result when I parse the json object in my client. The column Character customersMname is defined in the domains static constraints as:

customersMname nullable: true, maxSize: 1

the result I get back from the JSON object when the field is null is:

<jsonname2>customersMname</jsonname2>
<jsonvalue2>{"class":"java.lang.Character"}</jsonvalue2>

There is actual data in the database column and it should be P. Seems this is occurring with single character columns in MYSQL db when the datatype is defined as CHAR(1) or VARCHAR(1). Any ideas?


Solution

  • Apparently this is a bug in the system. Work around is to change the domain type to String and be done with it.