Database Reference
In-Depth Information
The CRUD operation is explained as follows:
The create operation : The following code shows the creation of an
employee record:
Employee employee = new Employee();
employee.setEmployeeId("1");
employee.setEmployeeName("John");
employee.setAddress("Atlanta");
employee.setDepartment("R&D Labs");
// persist employee record.
em.persist(employee);
Once the employee record is created, run the scan command to view the
record stored, as shown in the following screenshot:
The read operation : The following code shows the reading of the
employee record:
System.out.println("Finding employee record operation.");
// Find persisted employee record.
Employee foundEmployee = em.find(Employee.class, "1");
System.out.println(foundEmployee.getEmployeeId());
System.out.println(foundEmployee.getEmployeeName());
System.out.println(foundEmployee.getAddress());
System.out.println(foundEmployee.getDepartment());
 
Search WWH ::




Custom Search