3 Replies Latest reply on Feb 13, 2003 7:12 AM by Stephen Coy

    CMP converts empty string to space

    jameshr Newbie

      We run jboss-3.0.2 on Win2000 using SqlServer7. The problem occurs when we invoke a CMP getter on a varchar database column whose value is the empty string (ie length 0). Instead of returning an empty string, the getter returns a space, length 1. Non-zero length values and null values behave fine. As a work-around, we have been plugging trim()'s in the getter's.

      This CMP issue is inconsistent in nature. For example, if the table Facility has 5 varchar fields, this behavior may only be exhibited in only 1 or 2 fields, in this case the Contact field. I would have expected to see the issue across all 5 fields.

      Also, if I add a Facility record leaving Facility.Contact empty and then retrieve the record, I note the data looks fine. An update operation gives the same result. But, if I stop/restart JBoss and then retrieve the data, the problem occurs. This tells me that it's an issue related to the CMP JDBC code that retrieves data from the database into the bean.