i am using hibernate annotations, at the back end i am using Postgres SQL 8.3. So, i don't know how to apply sequence in annotations of my Class.
Plz provide related help for this.
i am using hibernate annotations, at the back end i am using Postgres SQL 8.3. So, i don't know how to apply sequence in annotations of my Class.
Plz provide related help for this.
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
Then, put this in front of your sequence field:
@GeneratedValue(strategy=GenerationType.SEQUENCE)
hope that was of any help...
You can have more control over the generated sequence by implementing it like this:
@Id
@GeneratedValue(generator="YourGeneratorName")
@GenericGenerator(
name="YourGeneratorName", strategy="seqhilo",
parameters={
@Parameter(name="max_lo", value="1"),
@Parameter(name="sequence", value="seq_name_of_the_sequence")
}
)
private Long id;