The word "POJO" stands for "Plain Old Java Object".The term "POJO" was coined by Martin Fowler, Rebbecca Parsons and Josh MacKenzie as they wanted to provide some "fancy Name". "POJO" refers to the Java Objects that does not serve any special function nor it uses any Special Conventions as in Java nor its supports any frameworks.
Basically POJO class is a class that has some attributes along with getters and setters methods defined in a class. "POJO" has following properties:
Does not have any technological dependence.
Any java object can run in EJB container
Enables developers to develop enterprise-class applications in Spring , Hibernate etc...
Very simple to made and every field in this is publicly accessible
Decouples the application components from the infrastructure of the EJB framework that lets you construct an application from loosely coupled components
The sample POJO class is described below..
public class Person {
private int id;
private String firstName;
private String lastName;
private int salary;
Person(String fname,String lname,int salary)
{
this.setFname(fname);
this.setLname(lname);
this.setSalary(salary);
}
public String getLname() {
return lastName;
}
public void setLname(String lname) {
this.lastName = lname;
}
public String getFname() {
return firstName;
}
public void setFname(String fname) {
this.firstName = fname;
}
public int getSalary() {
return salary;
}
public void setSalary(int salary) {
this.salary = salary;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}
0 Comment(s)