title: Problem with hibernate trigger-generated ids (MySQL)
body: <p>I'm using before and after insert triggers to generate ids (primary key) of the form "ID_NAME-000001" in several tables. At the moment, the value of the hibernate generator class of these pojos is <strong>assigned</strong>. A random string is assigned to the object to be persisted and when it's inserted by hibernate, the trigger assigns a correct id value.</p>
  
  <p>The problem with this approach is that I'm unable to retrieve the persisted object because the id only exists in the database, not in the object I just saved.</p>
  
  <p>I guess I need to create a custom generator class that could retrieve the id value assigned by the trigger. I've seen an example of this for oracle (<a href="https://forum.hibernate.org/viewtopic.php?f=1&amp;t=973262" rel="nofollow">https://forum.hibernate.org/viewtopic.php?f=1&amp;t=973262</a>) but I haven't been able to create something similar for MySQL. Any ideas?</p>
  
  <p>Thanks,</p>
  
  <p><strong>update:</strong></p>
  
  <p>Seems that this is a common and, yet, not solved problem. I ended up creating a new column to serve as a unique key to use a <strong>select</strong> generator class.</p>