What is the purpose of the @Transient 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: "To mark a field as not persistent (not to be stored in the database)". Theo JPA, mọi trường của thực thể mặc định đều được ánh xạ thành cột; đặt @Transient lên một trường báo persistence provider bỏ qua nó, không tạo cột, không đọc ghi, thường dùng cho giá trị tính toán như tuổi suy ra từ ngày sinh hay trường tạm chỉ dùng trong bộ nhớ. Cần phân biệt với từ khoá transient của Java vốn chủ yếu liên quan tuần tự hoá. "To specify a primary key" là việc của @Id. "To define a relationship between entities" là việc của @OneToMany, @ManyToOne, @ManyToMany hay @OneToOne. "To indicate a read-only field" sai vì trường @Transient hoàn toàn không gắn với cơ sở dữ liệu; muốn cột chỉ đọc thì dùng @Column với insertable và updatable bằng false, hoặc @Immutable của Hibernate cho cả thực thể.
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 annotation is used to define a JPA Many-to-Many relationship?Có lời giảiCâu hỏiWhat is the purpose of the @Column annotation in 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