Supposing that you have created an Oracle sequence using:

SQL> create sequence AGENDA_SEQ

Now, in your Entity define  SequenceGenerator which points to the sequence via the sequenceName attribute:

@Id
@GeneratedValue(strategy=GenerationType.AUTO, generator="my_entity_seq_gen")
@SequenceGenerator(name="my_entity_seq_gen", sequenceName="AGENDA_SEQ", allocationSize = 1)
private Long id;

Note that you can achieve the same result in Hibernate by mapping the Sequence in the XML configuration file:

<id name="id" type="java.lang.Integer">   

<column name="ID" />   

  <generator class="sequence-identity" >       

   <param name="sequence">AGENDA_SEQ</param>   

  </generator>

</id>
0
0
0
s2smodern