title: How do I annotate Id column if value is generated by a trigger?
body: <p>I have a setup with Oracle XE 10g, Hibernate 3.5, JPA 2.0. There is a simple table with a primary key, which is generated by a database trigger at insertion. The trigger gets the value from a sequence. The trigger/sequence construction was made by Oracle XE.</p>
  
  <p>The actual question is: How do I get the current value of the Id in my entity after a EntityManager.persist?<br>
  I tried:</p>
  
  <pre><code>@Id
  private long id;
  </code></pre>
  
  <p>-> id is <code>0</code>;</p>
  
  <pre><code>@Id
  @Generated(GenerationTime.ALWAYS)
  @Column(insertable = false, updatable = false)
  private long id;
  </code></pre>
  
  <p>-> id is <code>0</code>;</p>
  
  <pre><code>@Id
  @GeneratedValue(strategy=GenerationType.AUTO)
  private long id;
  </code></pre>
  
  <p>-> Fails because Hibernate is trying to query the a sequence directly (which does not exist).</p>
  
  <p><em>IDs are generated in the database in the first two approaches, but I don't have the value in my object</em>.</p>