1 2 3 4 5 6 7 | <employee> <employeeId>101</employeeId> <employeeName>employee Name</employeeName> <address>XYZ C Block, Bangalore-560025</address> <email>employee email</email> <telephone>5551234567</telephone> </employee> |
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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | package openJpa.model; /** * Persistent Class for Employee * OpenJPA enables writing persistent classes in a very transparent way */ import java.io.Serializable; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.persistence.Version; @Entity /*Each entity represents a relational datastore record. In this code all employee records will be stored in a table called CF_EMPLOYEE */ @Table(name="CF_EMPLOYEE") /* Databases allow Native sequences to be created , which are database structures that generates increasing numeric values. SequenceGenerator annotation represents a named database Sequence */ @SequenceGenerator(name="employeeSeqGen", sequenceName="native(Sequence=CF_EMPLOYEE_SEQ)") public class _Employee implements Serializable { private static final long serialVersionUID = 1L; public _Employee() { super(); } /*All entity classes must declare one or more fields which together forms the persistent identity of an instance.Every employee will have an unique employeeID which is the persistent identity */ @Id @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="employeeSeqGen") private int employeeId; /* OPEN JPA uses version field in entities to detect concurrent modifications to the same datastore record.Version field is optional for any entity, but without one concurrent threads or processes might succeed in making conflicting changes to the same record at the same time. */ @Version private int version; private String employeeName; private String address; private String email; private int telephone; public void setEmployeeId(int employeeId) { this.employeeId = employeeId; } public int getEmployeeId() { return employeeId; } public void setVersion(int version) { this.version = version; } public int getVersion() { return version; } public void setEmployeeName(String employeeName) { this.employeeName = employeeName; } public String getEmployeeName() { return employeeName; } public void setAddress(String address) { this.address = address; } public String getAddress() { return address; } public void setEmail(String email) { this.email = email; } public String getEmail() { return email; } public void setTelephone(int telephone) { this.telephone = telephone; } public int getTelephone() { return telephone; } } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |