title: org.springframework.beans.factory.BeanCreationException when using the same object from singleton
body: <p>I write server based on Springboot.I have <code>MonsterFactory</code> in which I have <code>MonsterType</code> objects, where MonsterType is entity.</p>
  
  <pre><code>public class MonsterFactory {
  
      public static final MonsterFactory INSTANCE = new MonsterFactory();
      private Map&lt;String,MonsterType&gt; monsterTypesMap = new HashMap&lt;&gt;();
  
      private MonsterFactory(){
          monsterTypesMap.put("Fire Golem", new MonsterType("Fire Golem","Opis",
              new MonsterStats(100,40,30,10),"/jakis/path"));
          monsterTypesMap.put("Bat", new MonsterType("Bat", "Opis 2",
              new MonsterStats(50,20,30,40),"/jakis/path2"));
      }
  
      public Monster create(final String name, Location location){
          MonsterType monsterType = monsterTypesMap.get(name);
          if(monsterType == null)
              throw new UnsupportedOperationException("unknown monster type");
          return new Monster(monsterType,location);
     }
  }
  </code></pre>
  
  <p>Now when I want to add some Monster objects to my <code>MonsterRepostory monsters</code> like this:</p>
  
  <pre><code>monsters.save(MonsterFactory.create("Fire Golem", new Location(40,80));
  monsters.save(MonsterFactory.create("Fire Golem", new Location(50, 80));
  </code></pre>
  
  <p>I get <code>org.springframework.beans.factory.BeanCreationException</code>.</p>
  
  <p>Is it problem that I use the same instance of <code>MonsterType</code> object for creating two different monsters or what? I'm new in Spring and Hibernate and don't know where the problem comes from.</p>
  
  <p>EDIT:
  okay, I found that I get nested exception: <code>org.springframework.dao.InvalidDataAccessApiUsageException: detached entity passed to persist</code>    </p>