Entering content frame

Procedure documentation Developing the EmployeeData Class Locate the document in its SAP Library structure

Use

The instances of the EmployeeData class are data transfer objects (DTO), which wrap the employee-related data exchanged between the persistence and the presentation layer.

Prerequisites

You must have created the GettingStartedOpenSQLWeb project.

Procedure

In...

       1.      In the Java perspective, choose GettingStartedOpenSQLWeb and open the context menu. Choose New ® Package. Enter temp.persistence.gettingstarted.dao as the package name.

       2.      Choose Finish.

       3.      From the context menu of GettingStartedOpenSQLWeb choose New ® Class. To choose a package for the class, use Browse… next to the Package field, and select temp.persistence.gettingstarted.dao from the list.

       4.      Enter EmployeeData in the Name field.

       5.      Choose Add… next to the Interfaces field. Enter Serializable in the Choose interfaces field. Select Serializable interface from java.io package and confirm the selection by choosing OK.

       6.      Choose Finish.

       7.      The Java file is created and opens automatically. You can enter the code for the EmployeeData class.

Example

package temp.persistence.gettingstarted.dao;

 

import java.io.Serializable;

import java.math.BigDecimal;

 

public class EmployeeData implements Serializable {

  

   int _empId;

   String _firstName;

   String _lastName;

   BigDecimal _salary;

   int _depId;

  

   // the constructor

   public EmployeeData(int empId, String firstName, String lastName, BigDecimal salary, int depId) {

      _empId = empId;

      _firstName = firstName;

      _lastName = lastName;

      _salary = salary;

      _depId = depId;

   }

 

    // the getter methods

   public int getDepId() {

      return _depId;

   }

 

   public int getEmpId() {

      return _empId;

   }

 

   public String getFirstName() {

      return _firstName;

   }

 

   public String getLastName() {

      return _lastName;

   }

 

   public BigDecimal getSalary() {

      return _salary;

   }

}

 

       8.      Save and close the file.

Result

You have created the EmployeeData class. Go on with developing the data access interface.

 

Leaving content frame