25.02.2015 Views

Introducing Spring Framework

Introducing Spring Framework

Introducing Spring Framework

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 5 ■ Working with Collections and Custom Types<br />

Listing 5-5. mydocuments-context.xml<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

Merging Collections<br />

The <strong>Spring</strong> <strong>Framework</strong> also provides a merge mechanism for the collections. In other words, you can have another<br />

bean of the same type with a different set of values and you can actually merge/join collections and avoid duplicates<br />

or add more to a set of values. Let’s see an example. Imagine you have the typeDAO bean but you want to add more<br />

entries that maybe could be in another XML configuration. This approach of merging collections can be beneficial<br />

if you are required to have a template or a base where you need to join or inherit some values. See Listing 5-6 for a<br />

merge example.<br />

57

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!