title: JPA 2, JSF, setting id of OneToOne mapped entity problem
body: <p>we havent used JPA or any other ORM tools in our web application, now we have been on updating whole stuff to Java EE 6,<br>
  my problem about is JPA 
  ,i have been looking for an answer,and learn how people solve that kinda issue,
  i have 2 entites, 
  <br/></p>
  
  <pre>
  <code>
  @Entity Person
  {
  @Id
  private long id;
  
  @JoinColumn(name="CITY_ID")
  @OneToOne(fetch=FetchType.LAZY)
  private City city;
  ....
  }
  
  </code>
  </pre>
  
  <p>and my second entity</p>
  
  <pre>
  
  @Entity City
  {
  @Id
  private long id;
  private String name;
  .....
  }
  </pre>
  
  <p>i am querying person entity and i show one on my jsf page</p>
  
  <p>i have 2 input fields for Person.city to show on my jsf page
  inputhidden for id and inputtext for name
  people are selecting cities from a popup then 
  i set hidden  component for city id, with new selected new value, 
  and the same for name,
  everthing goes fine till now,
  when i merge Person Entity, it tries to merge City also, but with an id already defined on table, so constraint error for Cirty Id.</p>
  
  <p>what are you doing for this kinda problem?</p>
  
  <p>i thought valueChange action for inputHidden,but at jsf Life cycle it happens before update model so even if i replace Person.City entity with new one in action ,
  it will updated again (actually with the same values but it will be done twice)
  ,So what is the best workaround for this situation?</p>
  
  <p>thanx</p>