Hibernate 4.1.6 Final
08:03 08 Jun 2026

Friends ,I am learning Hibernate ORM Tool ,In this i learnt from GFG (https://www.geeksforgeeks.org/java/hibernate-get-and-load-method/) There is and Two Types of fetching one is GET and LOAD ,one is eagerly fetch the data from database ,and LOAD fetch only the Proxy Object ,if use that Obj it fetch the real Object from database but in my code LOAD and GET work as same ,I do not know why Let me help to Understand.(I am using lombok to generate the Getter and Setter and Construtors)

    public class App{
        public static void main(String[] args){
            
                Configuration config = new Configuration().configure("hibernate.cfg.xml").addAnnotatedClass(Laptop.class);
                ServiceRegistry registry = new ServiceRegistryBuilder().applySettings(config.getProperties()).buildServiceRegistry();
                
                SessionFactory factory = config.buildSessionFactory(registry);
                Session session = factory.openSession();
                
                session.beginTransaction();
                
                Laptop lenovo = (Laptop)session.load(Laptop.class,101);
                
                System.out.println(lenovo.getClass().getName());
                session.getTransaction().commit();
                session.close();
                
                System.out.println(lenovo);
        }
    }


@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Laptop {
    @Id
    Integer id;
    String brand;
    Double price;
}


        org.hibernate
        hibernate-core
        4.1.6.Final
        compile
    
    
    
    
        mysql
        mysql-connector-java
        8.0.31
        compile
    
    
    
    
        org.projectlombok
        lombok
        1.18.42
        compile
    
java hibernate