title: Spring bean map with dynamic keys and values
body: <p>Right now i've application related data in spring bean map and passed this map to other classes as ref.</p>
  
  <p>Map is defined as below</p>
  
  <pre><code>&lt;bean id="sampleMap" class="java.util.HashMap"&gt;
      &lt;constructor-arg index="0" type="java.util.Map"&gt;
          &lt;map key-type="java.lang.Integer" value-type="java.lang.Float"&gt;
              &lt;entry key="1" value="5"/&gt;
              &lt;entry key="2" value="10"/&gt;
              &lt;entry key="3" value="15"/&gt;             
          &lt;/map&gt;
      &lt;/constructor-arg&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>This map is referred in other beans as</p>
  
  <pre><code>&lt;bean id="config" class="com.example.Config" abstract="false"&gt;      
      &lt;property name="sampleMap" ref="sampleMap"/&gt;
      .
      .
  &lt;/bean&gt;
  </code></pre>
  
  <p>I just want to retrieve the map values from database table and want to inject that to other classes. How can i do that in spring. Basically that table contains application related data.The key and values of map will be int,Configuration.</p>
  
  <p>What is the best place to load the configuration data? can we do with spring beans map or is there any other good approach to load configuration from database and refer that in other places of application like service,delegate and DAO?</p>
  
  <p>Help will be appreciated</p>
  
  <p>Thanks</p>