What is the purpose of the @Column annotation in JPA?
4 phương ánCó giải thích
Các phương án trả lời
Chọn một phương ánLời giảiChọn phương án để mở
Đáp án đúng: "It maps an entity field to a table column and allows setting column attributes". Trong JPA, mỗi trường persistent của entity mặc định ánh xạ tới cột cùng tên; @Column cho phép ghi rõ tên cột và các thuộc tính như name, nullable, unique, length, precision, scale, insertable, updatable, columnDefinition, ví dụ @Column(name = "full_name", nullable = false, length = 100). Hibernate dùng các thông tin này khi sinh DDL tạo bảng và khi dựng câu SQL. "It specifies the primary key field of an entity" là vai trò của @Id, thường đi cùng @GeneratedValue để sinh giá trị khoá. "It marks a field that should not be persisted" là @Transient, trường đó bị bỏ qua hoàn toàn khi lưu và nạp. "It defines a many-to-many relationship" là @ManyToMany, thường kèm @JoinTable để mô tả bảng nối giữa hai entity.
Cùng phần 1
If you have a Student entity and a Course entity with a Many-to-Many relationship, and you want to fetch all students enrolled in a specific course, how would you typically structure the query in JPA?Có lời giảiCâu hỏiWhich JPA feature allows relationships between tables?Có lời giảiCâu hỏiWhat best describes the Java Persistence API (JPA)?Có lời giảiCâu hỏiCả 40 câu của chủ đề40 câu
Xuất hiện trong 1 bộ đề
Đi tiếp từ đây