title: Using spring @Transactional for the beans created using factory method?
body: <p>I am using spring3. I have below classes. </p>
  
  <h2>Transport.java</h2>
  
  <pre><code>package com.net.core.ioc;
  
  public interface Transport {
    public void doSave();
  }
  </code></pre>
  
  <h2>Car.java</h2>
  
  <pre><code>package com.net.core.ioc;
  
      public class Car implements Transport{
       String name;
       public Car(String name){
           this.name=name;
        }
          public void doSave(){
              //saving logic using name
          }
      }
  </code></pre>
  
  <h2>Bus.java</h2>
  
  <pre><code>package com.net.core.ioc;
  
      public class Bus implements Transport {
        String id;
        public Bus(String id){
           this.id=id;
        }
          public void doSave() {
              //saving logic using id
          }
  </code></pre>
  
  <h2>SpringService.java</h2>
  
  <pre><code>package com.net.core.ioc;
  
      public class ServiceLocator {
          private static ServiceLocator service = new ServiceLocator ();
  
          //Static factory method
          public static ServiceLocator createService(){
              return service;
          }
  
          //Instance factory methods
          public Transport createCarInstance(String name){
          return new Car(name);
          }
  
      public Transport createBusInstance(String id){
              return new Bus(id);
          }
  
      }
   }
  </code></pre>
  
  <h2>config.xml</h2>
  
  <pre><code>&lt;context:component-scan base-package="com.net.core.ioc"/&gt;
          &lt;bean id="serviceLocator" class="com.net.core.ioc.ServiceLocator"factory-method="createService"/&gt;
          &lt;bean id="springServiceCarInstance" factory-bean="serviceLocator" factory-method="createCarInstance" scope="prototype"/&gt;
          &lt;bean id="springServiceBusInstance" factory-bean="serviceLocator" factory-method="createBusInstance" scope="prototype"/&gt;
      &lt;/beans&gt;
  </code></pre>
  
  <p>Now i am getting beans as below:</p>
  
  <pre><code>Transport request = (Transport)applicationContext.getBean("springServiceCarInstance","someName");
  request.doSave();
  </code></pre>
  
  <p><strong>Now can i use spring transactions here ? I mean can i annotate Car and Bus classes using @Transactional ?</strong> </p>