Oracle treating empty string as NULL problem for a Java / JPA programmer Oracle treating empty string as NULL problem for a Java / JPA programmer oracle oracle

Oracle treating empty string as NULL problem for a Java / JPA programmer


Yup, that's the way Oracle functions. Empty strings are treated as nulls.

You can of course "fix" this on application level - for example by storing " " values as you suggested - but first consider, what exactly is the difference with your "empty string" values compared to NULL values? Why do you need to treat them differently? I used to run into this dilemma, too, but usually found out that there are very few cases where I really need to tell the difference.


No, there is no way to treat empty strings as empty strings. Oracle always treats a string of length zero as a NULL value.


It´s not only the selection with special where condition but also the treating of Java String Objects.If you have a String a="" you can call its length method and get 0.If you have a String a=null you get a nullpointer exception when calling length. So working with an oracle db forces you to always check if your string is null before checking length :(