title: Creating new entities while enabling injection
body: <p>I have a method on a stateless session bean which creates a new instance of an entity and persists it. You might normally use new MyEntity() to create the object but I would like injection to populate some of the properties of the entity for me.</p>
  
  <p>I got partial success using </p>
  
  <pre><code>@Inject 
  @New 
  private MyEntity myNewEntity; 
  </code></pre>
  
  <p>in the session bean and then using that instance in my method.</p>
  
  <p>The problem I have now is that the second time the method is called, myNewEntity isn't a new object, its the same object as the one created the first time. As a result I'm getting </p>
  
  <p>com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '9' for key 'PRIMARY' </p>
  
  <p>Or at least that's why I think I'm getting this exception. Certainly if I use new MyEntity() I don't get the exception but my injection doesn't happen.</p>
  
  <p>Am I on the wrong track? How can I create a new local entity object while enabling injection?</p>
  
  <p>Any help would be great!</p>