title: JPA 2.0 + One to One + Shared Primary Key not being set
body: <p>Have to two tables Customer and Upload, where I track the number of items the customer has uploaded.  It is a one to one relationship with a shared primary key <code>CustomerID</code>, which is a unique identifier. I am struggling trying to get the save to work. I am using Hibernates uuid2 strategy to handle the creation/saving of the unique identifiers.  Before I included the Upload entity, Customer would save correctly with a uuid.  Basically I want the upload to be created whenever someone makes a customer object.</p>
  
  
  
  <p><strong>Customer:</strong></p>
  
  <pre class="lang-java prettyprint-override"><code>@Entity
  public class Upload implements Serializable {
      @Column(name="UPLOADCOUNT",    nullable=true,  unique=false)
      private Integer uploadCount = new Integer(0); 
  
      @MapsId ("CUSTOMERID")
      @OneToOne (optional=false)
      @JoinColumn(name="CUSTOMERID", referencedColumnName = "CUSTOMERID", nullable=false,  unique=true ) 
      private Customer customer;  
  
      @Id 
      @Column(name="CUSTOMERID", length=36, nullable=false, unique=true, insertable=false, updatable=false)
      private String customerId_;
  
       public Upload(Customer customer) {    
           this.customer = customer;
       }
  }
  </code></pre>
  
  <p><strong>Upload:</strong></p>
  
  <pre class="lang-java prettyprint-override"><code>@Entity
  public class Customer implements Serializable {
  
  
      @Id
      @Column(name = "CUSTOMERID", unique = true)
      @GeneratedValue(generator = "uuid")
      @GenericGenerator(name = "uuid", strategy = "uuid2")
      private String customerId;
  
      @OneToOne(mappedBy = "customer", optional = false, cascade = CascadeType.ALL)
      private Upload upload ; 
  
  
      public Customer() {
          this.upload = new Upload(this);        
      }
  }
  </code></pre>
  
  <p><strong>Code to save:</strong></p>
  
  <pre class="lang-java prettyprint-override"><code>Customer customer = new Customer();
  EntityManager em = EntityManagerUtil.getEntityManager();
  EntityTransaction trans = em.getTransaction();
  
  trans.begin();
  em.persist(customer);
  trans.commit();
  </code></pre>
  
  <p><strong>Exception:</strong></p>
  
  <pre class="lang-java prettyprint-override"><code> javax.persistence.PersistenceException: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): Upload
  </code></pre>