Setting null values in spring
Posted on 2011-05-04
I was reading folowing lines and I did not understand clearly.
Setting null values:
what if in order to satisfy a requirement you need to explicitly set a property to null.
This is really
just another kind of wiring, only in this case we are wiring null instead of a value
To set a property to null, you simply use the <null/> element.
For example, to
set a foo property to null, you’d use this:
Why would you ever need to do this? If you do not explicitly wire a property in
Spring, you may assume that the property is left null. But that’s not always true.
For one thing, the bean itself may set the property to some default value. Or, if
you are using autowiring, the property may be implicitly wired. In either case, you
may need to use <null/> to explicitly set the property to null.
Any ideas, resources,sample code,links, highly appreciated. thanks in advance.