Last active
November 20, 2020 10:31
-
-
Save susimsek/19a1fa97943a89dfdc70144dad14e0a1 to your computer and use it in GitHub Desktop.
Lombok Builder Extends with Jpa
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
@Setter | |
@Getter | |
@NoArgsConstructor | |
@AllArgsConstructor | |
@SuperBuilder | |
@MappedSuperclass | |
public class BaseEntity { | |
@Id | |
@GeneratedValue(generator = "UUID") | |
@GenericGenerator( | |
name = "UUID", | |
strategy = "org.hibernate.id.UUIDGenerator" | |
) | |
@Type(type="org.hibernate.type.UUIDCharType") | |
@Column(length = 36, columnDefinition = "varchar", updatable = false, nullable = false ) | |
private UUID id; | |
@Version | |
private Long version; | |
@CreationTimestamp | |
@Column(updatable = false) | |
private Timestamp createdDate; | |
@UpdateTimestamp | |
private Timestamp lastModifiedDate; | |
public boolean isNew() { | |
return this.id == null; | |
} | |
} |
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
@Getter | |
@Setter | |
@NoArgsConstructor | |
@AllArgsConstructor | |
@SuperBuilder | |
@Entity | |
public class Customer extends BaseEntity { | |
private String customerName; | |
@Column(length = 36, columnDefinition = "varchar") | |
private UUID apiKey; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment