Back to list

JPA/Hibernate - Entity Definition

Lv.5512@mukitaro11 playsDec 31, 2025

JPA entity with Hibernate annotations for ORM mapping. Shows table mapping, relationships, and automatic timestamp handling.

preview.java
Java
1@Entity
2@Table(name = "products")
3public class Product {
4 @Id
5 @GeneratedValue(strategy = GenerationType.IDENTITY)
6 private Long id;
7
8 @Column(nullable = false, length = 100)
9 private String name;
10
11 @Column(precision = 10, scale = 2)
12 private BigDecimal price;
13
14 @ManyToOne(fetch = FetchType.LAZY)
15 @JoinColumn(name = "category_id")
16 private Category category;
17
18 @CreationTimestamp
19 private LocalDateTime createdAt;
20
21 @UpdateTimestamp
22 private LocalDateTime updatedAt;
23}

Custom problems are not included in rankings