-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJPAExample.java
More file actions
37 lines (33 loc) · 944 Bytes
/
JPAExample.java
File metadata and controls
37 lines (33 loc) · 944 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* Day 38 - Spring Data JPA: Entity Example
*
* Note: Requires JPA/Hibernate dependencies
*/
// @Entity
// @Table(name = "users")
// public class User {
// @Id
// @GeneratedValue
// private Long id;
//
// @Column(nullable = false)
// private String name;
//
// @Column(unique = true)
// private String email;
// }
//
// @Repository
// public interface UserRepository extends JpaRepository<User, Long> {
// User findByEmail(String email);
// }
public class JPAExample {
public static void main(String[] args) {
System.out.println("=== Spring Data JPA ===\n");
System.out.println("@Entity: Maps class to database table");
System.out.println("@Id: Marks primary key");
System.out.println("@Column: Defines column properties");
System.out.println("@Repository: Data access layer");
System.out.println("JpaRepository: Provides CRUD operations");
}
}