Skip to content

Instantly share code, notes, and snippets.

@michail-nikolaev
Created September 9, 2012 22:41
Show Gist options
  • Save michail-nikolaev/3687754 to your computer and use it in GitHub Desktop.
Save michail-nikolaev/3687754 to your computer and use it in GitHub Desktop.
JPA - PostgreSQL - AbstractEntity with common ID sequence
@MappedSuperclass
public abstract class AbstractEntity<T extends AbstractEntity> {
private static final String SEQUENCE_NAME = "id_seq";
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = SEQUENCE_NAME)
@SequenceGenerator(name = SEQUENCE_NAME, sequenceName = SEQUENCE_NAME)
private Long id;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment