Skip to content

Instantly share code, notes, and snippets.

@loomismilitia
Forked from odrotbohm/AbstractAuditable.java
Last active October 21, 2017 08:41
Show Gist options
  • Save loomismilitia/7019b68709c908813663e774e84cf49a to your computer and use it in GitHub Desktop.
Save loomismilitia/7019b68709c908813663e774e84cf49a to your computer and use it in GitHub Desktop.
@MappedSuperclass
public abstract class AbstractAuditable<U, PK extends Serializable> extends AbstractPersistable<PK> implements
Auditable<U, PK> {
// …
}
@MappedSuperclass
public abstract class AbstractPersistable<PK extends Serializable> implements Persistable<PK> {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private PK id;
// …
}
@Entity
public class AuditableUser extends AbstractAuditable<AuditableUser, Long> {
// …
}
interface Persistable<ID extends Serializable> extends Serializable {
ID getId();
boolean isNew();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment