title: Hibernate and PostgreSQL: Can I configure GenerationType.IDENTITY, where each id column's default value comes from a shared sequence?
body: <p>Ok I am not 100% sure if I really want this but currently it seems like a good idea.</p>
  
  <p>I configure my entities like this:</p>
  
  <pre><code>@Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private long id = 0;
  </code></pre>
  
  <p>If I let Hibernate generate the table, the result is:</p>
  
  <pre><code>  id bigserial NOT NULL,
    CONSTRAINT test_pkey PRIMARY KEY (id)
  </code></pre>
  
  <p>The bigserial in turn translates into a bigint with a default value of:</p>
  
  <pre><code>nextval('test_id_seq'::regclass)
  </code></pre>
  
  <p>Now that's ok but I am currently considering using a single sequence for all tables and would like the default value to be:</p>
  
  <pre><code>nextval('my_global_sequence'::regclass)
  </code></pre>
  
  <p>Maybe I could go and manually adjust the default value later, but do you have any ideas how I could tell hibernate to define the table like this automatically? Is there maybe a way to push my own create table sql strategy that would issue code like this for the id column (untested SQL syntax):</p>
  
  <pre><code>id bigint NOT NULL DEFAULT = nextval('my_global_sequence'::regclass)
  </code></pre>
  
  <p>Note that I would like to stick with the IDENTITY strategy, because I want to avoid any "hi/lo multiplying allocation size cache sequence whatever"-strategies. From time to time I need to insert some manual rows through pgAdmin without risking any id conflict with hibernate. All the other strategies seem like magic to me (= I don't understand them).</p>