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

后端 未结 6 2394
失恋的感觉
失恋的感觉 2021-02-19 17:22

How do you handle this situation where Oracle stores the empty string as a null in the database ?

I would like it to be stored as an empty string as it is not as NULL, s

6条回答
  •  后悔当初
    2021-02-19 17:39

    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.

提交回复
热议问题