[hibernate-issues] [Hibernate-JIRA] Created: (HHH-2370) Xml-persisted empty string are interpreted as null value

Daniele Castagna (JIRA) noreply at atlassian.com
Fri Jan 19 08:30:44 EST 2007


Xml-persisted empty string are interpreted as null value
--------------------------------------------------------

         Key: HHH-2370
         URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2370
     Project: Hibernate3
        Type: Bug

  Components: core  
    Versions: 3.2.2    
 Environment: All hibernate version, on all platform.
    Reporter: Daniele Castagna
    Priority: Minor
 Attachments: HEmptyString.tar.gz

NullableType.Object fromXMLString(String xml, Mapping factory) method returns null if the string is an empty string (string with a length of 0).

This creates some problems when you use xml persistence to export or import empty string property with the not-null costraint.
Look at the attachment simple project (or here: http://forum.hibernate.org/viewtopic.php?t=969755 ) for an example that will throw an unexpected exception.

This problem could be easily fixed removing the "|| xml.length()==0" boolean expression from the fromXMLString method.
I think that it would be better not only with strings but even with other types; for example an xml tag that should be interpreted as an Integer and contains an empty string should throw an exception, and should not return a null value. The null value is already represented by the absence of the xml tag.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira




More information about the hibernate-issues mailing list