02 Sử dụng hibernate cơ bản, cấu hình và thao tác cơ bản

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ต.ค. 2024

ความคิดเห็น • 21

  • @dieukhanhquach8489
    @dieukhanhquach8489 2 ปีที่แล้ว +2

    Bài giảng rất hay và rất có ích cho mônhojc em sau này, em cảm ơn thầy đã chia sẻ, chúc thầy mạnh khỏe ạ

  • @d-daymkk6795
    @d-daymkk6795 2 ปีที่แล้ว +1

    hay thật công nhận xịn luôn thầy

  • @NguyenPhuc-pt8bh
    @NguyenPhuc-pt8bh ปีที่แล้ว

    dạ mình remove là nó ở trạng tháy a persistent đk thầy

  • @74.nguyenvantung74
    @74.nguyenvantung74 ปีที่แล้ว

    cảm ơn thầy bài giảng hay quá ạ

  • @thuandau.rutvitrasau
    @thuandau.rutvitrasau 2 ปีที่แล้ว +1

    Thầy dạy hay quá

  • @DanhNguyen-lk2pm
    @DanhNguyen-lk2pm ปีที่แล้ว

    em cảm ơn thầy nhiều ạ

  • @duytam6597
    @duytam6597 ปีที่แล้ว

    phần spring data jpa thầy làm video không ạ

  • @nguyenkhanhduy200
    @nguyenkhanhduy200 ปีที่แล้ว

    thầy cho em hỏi với ạ sao cấu hình các thứ e chạy được rồi mà đến lúc câu lệnh save thì nó k hiện và nó cũng không lưu được vào database là tại sao ạ ,em cảm ơn

  • @phihonguyen9759
    @phihonguyen9759 3 ปีที่แล้ว

    bài giảng hay quá ạ

  • @NguyenPhuc-pt8bh
    @NguyenPhuc-pt8bh ปีที่แล้ว

    thầy có file sql database đó đucợ k thầy

  • @vuthien9342
    @vuthien9342 2 ปีที่แล้ว

    thầy ơi cho em hỏi, persistent class tại sao lại không nên kế thừa từ các lớp khác vậy thầy ? tại em hay mang những thuộc tính của những class chung như id, createdata, createby .... vào một parent class rồi cho kế thừa lại @@ . em cảm ơn thầy

    • @duonghuuthanh
      @duonghuuthanh  2 ปีที่แล้ว

      Mình có thể kế thừa bình thường, a tham khảo thử này www.baeldung.com/hibernate-inheritance#mappedsuperclass

    • @vuthien9342
      @vuthien9342 2 ปีที่แล้ว

      @@duonghuuthanh dạ em cảm ơn thầy, thầy dạy hay, dễ hiểu lắm ^^

  • @duyluat1298
    @duyluat1298 2 ปีที่แล้ว

    Em dùng SQL thì chỉ cần thay đường dẫn chỗ mình cấu hình là được thôi đúng không ạ thầy

    • @duonghuuthanh
      @duonghuuthanh  2 ปีที่แล้ว

      Thay đổi driver và các cấu hình liên quan.

  • @d-daymkk6795
    @d-daymkk6795 2 ปีที่แล้ว

    thầy em hỏi uniqueidentifier và UNIQUE thì mapping kiểu gì ạ

    • @duonghuuthanh
      @duonghuuthanh  2 ปีที่แล้ว

      Em có thể thử tham khảo chỗ này www.codementor.io/@petrepopescu/how-to-use-string-uuid-in-hibernate-with-mysql-1jrhjh6ef5

  • @ttnhieu8538
    @ttnhieu8538 3 ปีที่แล้ว

    thầy ơi, thầy post slide đc k ạ

    • @duonghuuthanh
      @duonghuuthanh  3 ปีที่แล้ว

      Tài liệu này lưu hành nội bộ nên ko post lên được nhé e!

    • @ttnhieu8538
      @ttnhieu8538 3 ปีที่แล้ว

      @@duonghuuthanh e cảm ơn ạ

  • @thanhtc1988
    @thanhtc1988 ปีที่แล้ว

    20:47 thực tế là em viết code của thầy lên IntelliJ nhưng thằng IntelliJ nó bị lỗi sao á, nó cứ detect cái hàm getProperties trong file Utils là của java.util chứ không phải là của pack hibernate hay javax.persistent gì đó nên nó bị lỗi. Em có thử cách khai báo với file Utils của bên GPCoder thì được, trong tutorial là: "Cài đặt và sử dụng Hibernate" . Về sau gặp lỗi Mapping exception thì trong file hibernate.cfg.xml thêm tag mapping trỏ đến đường dẫn của Class cần nối với bảng:
    package hibernatedemo;
    import org.hibernate.SessionFactory;
    import org.hibernate.boot.Metadata;
    import org.hibernate.boot.MetadataSources;
    import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
    import org.hibernate.service.ServiceRegistry;
    public class HibernateUtils {
    private static final SessionFactory sessionFactory = buildSessionFactory();
    private HibernateUtils() {
    super();
    }
    private static SessionFactory buildSessionFactory() {
    ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder() //
    .configure() // Load hibernate.cfg.xml from resource folder by default
    .build(); // có thể truyền đường dẫn file xml vào bên trong configure()
    Metadata metadata = new MetadataSources(serviceRegistry).getMetadataBuilder().build();
    return metadata.getSessionFactoryBuilder().build();
    }
    public static SessionFactory getSessionFactory() {
    return sessionFactory;
    }
    public static void close() {
    getSessionFactory().close();
    }
    }
    File: hibernate.cfg.xm


    org.hibernate.dialect.MySQLDialect


    com.mysql.cj.jdbc.Driver


    jdbc:mysql://localhost/saledb

    root
    123456