Java Reference
In-Depth Information
Adding persistent fields to our entity
At this point, our JPA entity contains a single field: its primary key. This is
admittedly not very useful. We need to add a few fields to be persisted to the
database, as shown in the following code:
package com.ensode.jpaweb;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
public class Customer implements Serializable {
private static final long serialVersionUID = 1L;
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String firstName;
private String lastName;
public Long getId() {
return id;
public void setId(Long id) { = id;
public String getFirstName() {
return firstName;
public void setFirstName(String firstName) {
this.firstName = firstName;
public String getLastName() {
return lastName;
Search WWH ::

Custom Search