In this JavaEE EJB tutorial, we will add Location Entity to the JPA Project. This time we will JPA tools to add all the annotations (@Table, #Column, @Id, @GeneratedValue)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
package tube.coding.examples.jpa.entity; import java.io.Serializable; import java.lang.String; import javax.persistence.*; /** * Entity implementation class for Entity: Location * */ @Entity //Sample 7.01: Point to Location Table @Table(name = "Location") public class Location implements Serializable { //Sample 7.02: Other Column Mappings @Id @Column(name = "Id") @GeneratedValue(strategy=GenerationType.IDENTITY) private int Id; @Column(name = "Street") private String Street; @Column(name = "City") private String City; private static final long serialVersionUID = 1L; public Location() { super(); } public int getId() { return this.Id; } public void setId(int Id) { this.Id = Id; } public String getStreet() { return this.Street; } public void setStreet(String Street) { this.Street = Street; } public String getCity() { return this.City; } public void setCity(String City) { this.City = City; } //Sample 7.03: String Representation of Entity @Override public String toString() { String ret; ret = this.Street + ", " + this.City; return ret; } } |
Categories: JavaEE-EJB-Tube