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, since issuing the query would be easier.
Something like this would select the empty string and non-empty string, but not the null values
select * from mytable where myfield like '%';
if i would like to select also the null values (which should be originally empty string), i would have to select like this :
select * from mytable where myfield like '%' or myfield is null;
i would love to skip doing or myfield is null
all the time later in my sql statements
The current solution i have in mind is to take care of this in the application level, for example, in the entity, i initialize all my String field default value to a space, for example :
@Entity
public class MyEntity {
private String name = " ";
public void setName(String name) {
if (isEmptyString(name)) {
name = " ";
}
}
...
}
Or perhaps, i can make use of a new type still unknown to me from Oracle 11g that can keep empty string as it is without changing it to null value ?
Thank you !