Configuring the null values

In Java, unless any of the values of the data member are not set, each will get their default ones. The reference properties will be defined as null, and primitive integers to 0 respectively. These nulls, later on, will be overridden by the set values by either constructor injection or setter injection. It may also be possible that developers want to keep it null until some business logic won't give the calculated value, or get it from some external resource. Whatever the reason, we will want to configure the value as null; simply use <null/>. The customer's address will be set to null as shown in the following lines of code:

<bean id="customer_obj" class="com.ch02.beans.Customer"> 
  <property name="cust_id" value="20"/> 
  <property name="cust_name" value="bob"/> 
  <property name="cust_address"><null/></property> 
</bean> 

You can find the configuration in customer.xml of Ch02_InnerBeans.

Up until now, we have seen the mapping of primitives, references, null, or inner beans. We are more than happy! But wait, there's a very important fundamental concept that we haven't discussed, and which we cannot afford to miss. I am talking about Java Collection framework. Yes, we are going to discuss the mapping of a collection.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.27.232