Skip to content

Instantly share code, notes, and snippets.

@javaeeeee
Created November 6, 2015 13:02
An Employee entity
@Entity
@Table(name = "employees")
@NamedQueries({
@NamedQuery(name = "com.javaeeeee.dwstart.core.Employee.findAll",
query = "select e from Employee e"),
@NamedQuery(name = "com.javaeeeee.dwstart.core.Employee.findByName",
query = "select e from Employee e "
+ "where e.firstName like :name "
+ "or e.lastName like :name")
})
public class Employee {
/**
* Entity's unique identifier.
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
/**
* employee first name.
*/
@Column(name = "first_name")
private String firstName;
/**
* employee last name.
*/
@Column(name = "last_name")
private String lastName;
/**
* employee position.
*/
@Column(name = "e_position")
private String position;
/**
* employee phone.
*/
private String phone;
/**
* employee e-mail.
*/
private String e_mail;
/**
* A no-argument constructor.
*/
public Employee() {
}
/**
* A constructor to create employees. Id is not passed, cause it's
* auto-generated by RDBMS.
*
* @param firstName employee first name
* @param lastName employee last name
* @param position employee position
* @param phone employee phone
* @param e_mail employee e-mail
*/
public Employee(String firstName, String lastName, String position, String phone, String e_mail) {
this.firstName = firstName;
this.lastName = lastName;
this.position = position;
this.phone = phone;
this.e_mail = e_mail;
}
// Auto-generated equald, hashCode, getters and setters.
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment