title: How to generate a default name for a DB entity that is not duplicate?
body: <p>I have a requirement to generate a unique name for a new instance of a database entity.</p>
  
  <p>Now, one option that readily seems like a good solution is giving a name like 'Unnamed EntityX - ID' where ID is the ID of the instance. Problem with this approach is we don't know the ID upfront.</p>
  
  <p>Another option is to save twice - once with an invalid name like 'Unnamed EntityX - RANDOM_NUMBER;%;' and then save again with name 'Unnamed EntityX - ID'.
  There are two issues with this approach:</p>
  
  <ol>
  <li>It seems incorrect to save twice.</li>
  <li>It seems incorrect to save with incorrect name even if temporary.</li>
  </ol>
  
  <p>A third option is to save with 'Unnamed EntityX - RANDOM_NUMBER' and if that is duplicate, then try the second option above.</p>
  
  <p>What's the best practice (or common practice) in this case? I feel like the second approach is the best option.</p>
  
  <p>Details: I am using grails 2.4.4 with native ID generation.</p>