[JPA & Hibernate] JPA & Hibernate Annotations

원알렉스·2020년 8월 10일
0

JPA

목록 보기
4/16
post-thumbnail
post-custom-banner

깃허브 소스코드
Udemy 강의영상

@Entity
@Table(name = "courses")
@NamedQuery(name = "query_get_all_courses", query = "SELECT C FROM Course C")
@Getter
@Builder
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Course {

    @Id
    @GeneratedValue
    private Long id;

    @Setter
    @Column(name = "name", nullable = false, length = 100)
    private String name;

    @UpdateTimestamp
    @Column(name = "updated_date", nullable = false)
    private LocalDateTime updatedDate;

    @CreationTimestamp
    @Column(name = "created_date", nullable = false)
    private LocalDateTime createdDate;

    @Override
    public String toString() {
        return String.format("Course[%s]", this.name);
    }
}

@Table

@Column

@UpdateTimeStamp

@CreationTimeStamp

@NameQuery

@NameQueries

profile
Alex's Develog 🤔
post-custom-banner

0개의 댓글