Last active
August 9, 2021 11:34
-
-
Save ereshzealous/d0c47116c5e35265250a18325e3d14fc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| package com.spring.hibernate.entity; | |
| import lombok.Data; | |
| import lombok.NoArgsConstructor; | |
| import org.hibernate.annotations.CreationTimestamp; | |
| import org.hibernate.annotations.GenericGenerator; | |
| import org.hibernate.annotations.UpdateTimestamp; | |
| import org.springframework.core.annotation.Order; | |
| import javax.persistence.CascadeType; | |
| import javax.persistence.Column; | |
| import javax.persistence.Entity; | |
| import javax.persistence.FetchType; | |
| import javax.persistence.GeneratedValue; | |
| import javax.persistence.Id; | |
| import javax.persistence.JoinColumn; | |
| import javax.persistence.ManyToOne; | |
| import javax.persistence.Table; | |
| import java.time.LocalDateTime; | |
| /** | |
| * Created on 09/August/2021 By Author Eresh, Gorantla | |
| **/ | |
| @Entity | |
| @Table(name = "address") | |
| @Data | |
| @NoArgsConstructor | |
| public class Address { | |
| @Id | |
| @GeneratedValue(generator = "system-uuid") | |
| @GenericGenerator(name = "system-uuid", strategy = "org.hibernate.id.UUIDGenerator") | |
| private String id; | |
| @Column(name = "address1") | |
| private String address1; | |
| @Column(name = "address2") | |
| private String address2; | |
| @Column(name = "street") | |
| private String street; | |
| @Column(name = "city") | |
| private String city; | |
| @Column(name = "state") | |
| private String state; | |
| @Column(name = "country") | |
| private String country; | |
| @Column(name = "created_at", updatable = false) | |
| @CreationTimestamp | |
| private LocalDateTime createdAt; | |
| @Column(name = "updated_at", insertable = false) | |
| @UpdateTimestamp | |
| private LocalDateTime updatedAt; | |
| @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) | |
| @JoinColumn(name = "user_id", referencedColumnName = "id") | |
| private UserDetails userDetails; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment