[ Published on -
1. Java - Primitives
2. Java - Strings
3. Java - Arrays
4. Java - Date
5. Java - Generics
6. Java - Collections
7. Java - Localization
8. Java - Formatting
9. Java - Regular Expressions
10. Java - System
11. Java - Serialization
12. Java - Multithreading
13. Java - IO/File
14. Java - Networking
15. Java - ORM - JPA
a) Simple User entity class
package jpa; import java.io.Serializable; import javax.persistence.*; /** * USER ENTITY CLASS * @author stanislav.zorjan */ @Entity @Table(name="users") @NamedQueries({ @NamedQuery(name="User.findAll", query="SELECT c FROM User c"), @NamedQuery(name="User.findByFirstName", query="SELECT c FROM User c WHERE c.firstName = :firstName"), @NamedQuery(name="User.findByLastName", query="SELECT c FROM User c WHERE c.lastName = :lastName"), @NamedQuery(name="User.findByAddress", query="SELECT c FROM User c WHERE c.address = :address") }) public class User implements Serializable{ @Id @GeneratedValue private Integer id; private String firstName; private String lastName; private String address; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } /** * @return the firstName */ public String getFirstName() { return firstName; } /** * @param firstName the firstName to set */ public void setFirstName(String firstName) { this.firstName = firstName; } /** * @return the lastName */ public String getLastName() { return lastName; } /** * @param lastName the lastName to set */ public void setLastName(String lastName) { this.lastName = lastName; } /** * @return the address */ public String getAddress() { return address; } /** * @param address the address to set */ public void setAddress(String address) { this.address = address; } @Override public String toString(){ return this.firstName+", "+this.lastName+", "+this.address; } }