Hibernate Persistent / Entity Class
- This class uses standard JavaBean naming conventions for property getter and setter methods, as well as private visibility for the fields. Although this is the recommended design, it is not required.
- The no-argument constructor, which is also a JavaBean convention, is a requirement for all persistent classes. Hibernate will create objects for you, using Java Reflection. The constructor can be private. However, package or public visibility is required for runtime proxy generation and efficient data retrieval without bytecode instrumentation.
Java classes whose objects or instances will be stored in database tables are called persistent classes or Entity classes in Hibernate.
Simple POJO Class
Employee.javapackage com.javatutorialcorner.pojo; public class Employee { private Long empId; private String firstName; private String lastName; private Integer age; private Double salary; public Long getEmpId() { return empId; } public void setEmpId(Long empId) { this.empId = empId; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public Integer getAge() { return age; } public void setAge(Integer age) { this.age = age; } public Double getSalary() { return salary; } public void setSalary(Double salary) { this.salary = salary; } }
0 comments:
Post a Comment