title: Unique key auto generated in Spring Boot Entity
body: <p>I have a primary key in my entity table which is autogenerated but now I want unique keys to be auto generated so how to do it
  Please help me out.</p>
  <pre><code>    @Entity
      @Table(name = &quot;director&quot;)
      public class Director {
      
          @Id
          @GeneratedValue(strategy = GenerationType.IDENTITY)
          @Column(name = &quot;id&quot;)
          private long id;
      
  //how to make this field auto generated like above one
          @Column(name = &quot;subid&quot;, unique=true)
          private long sub_id;
  </code></pre>
  <p>My database table picture is here please refer
  <a href="https://i.stack.imgur.com/f0zbN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/f0zbN.png" alt="table" /></a></p>