Created
September 9, 2012 22:41
-
-
Save michail-nikolaev/3687754 to your computer and use it in GitHub Desktop.
JPA - PostgreSQL - AbstractEntity with common ID sequence
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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