001 | package com.zyp.jpa2; |
002 |
003 | import java.util.Calendar; |
004 | import java.util.Collection; |
005 | import java.util.Date; |
006 | import javax.persistence.Basic; |
007 | import javax.persistence.Column; |
008 | import javax.persistence.Entity; |
009 | import javax.persistence.EnumType; |
010 | import javax.persistence.Enumerated; |
011 | import javax.persistence.FetchType; |
012 | import javax.persistence.GeneratedValue; |
013 | import javax.persistence.GenerationType; |
014 | import javax.persistence.Id; |
015 | import javax.persistence.JoinColumn; |
016 | import javax.persistence.JoinTable; |
017 | import javax.persistence.Lob; |
018 | import javax.persistence.ManyToMany; |
019 | import javax.persistence.ManyToOne; |
020 | import javax.persistence.OneToOne; |
021 | import javax.persistence.Table; |
022 | import javax.persistence.TableGenerator; |
023 | import javax.persistence.Temporal; |
024 | import javax.persistence.TemporalType; |
025 |
026 | @Entity |
027 | // @Table(name = "EMPLOYEE", schema = "HR") |
028 | @Table (name = "EMPLOYEE" , catalog = "HR" ) |
029 | public class Employee { |
030 |
031 | @Id |
032 | @Column (name = "emp_id" ) |
033 | @GeneratedValue (strategy = GenerationType.AUTO) |
034 | @TableGenerator (name = "key_gen" , table = "id_gen" , pkColumnName = "gen_name" , valueColumnName = "gen_value" , initialValue = 10000 , allocationSize = 100 ) |
035 | // @GeneratedValue(generator="key_gen") |
036 | private int id; |
037 |
038 | private String name; |
039 |
040 | private long salary; |
041 |
042 | @ManyToMany |
043 | @JoinTable (name= "EMP_PROJ" , |
044 | joinColumns= @JoinColumn (name= "EMP_ID" ), |
045 | inverseJoinColumns= @JoinColumn (name= "PROJ_ID" )) |
046 | private Collection<Project> projects; |
047 | |
048 | @ManyToOne |
049 | @JoinColumn (name = "DEPT_ID" ) |
050 | private Department department; |
051 |
052 | @OneToOne |
053 | @JoinColumn (name = "PSPACE_ID" ) |
054 | private ParkingSpace parkingSpace; |
055 |
056 | @Lob |
057 | @Column (name = "pic" ) |
058 | @Basic (fetch = FetchType.LAZY) |
059 | private byte [] picture; |
060 |
061 | @Enumerated (EnumType.STRING) |
062 | private Type type; |
063 |
064 | @Temporal (TemporalType.DATE) |
065 | private Date startDate; |
066 |
067 | @Temporal (TemporalType.DATE) |
068 | private Calendar dob; |
069 |
070 | transient private String translater; |
071 |
072 | public Employee() { |
073 | } |
074 |
075 | public Employee( int id) { |
076 | this .id = id; |
077 | } |
078 |
079 | public int getId() { |
080 | return id; |
081 | } |
082 |
083 | public void setId( int id) { |
084 | this .id = id; |
085 | } |
086 |
087 | public String getName() { |
088 | return name; |
089 | } |
090 |
091 | public void setName(String name) { |
092 | this .name = name; |
093 | } |
094 |
095 | public long getSalary() { |
096 | return salary; |
097 | } |
098 |
099 | public void setSalary( long salary) { |
100 | this .salary = salary; |
101 | } |
102 | |
103 | |
104 | |
105 | } |
106 |
107 | enum Type { |
108 | T1, T2, T3 |
109 | } |

flygrass LV12
2023年12月7日
zmlzsw LV8
2021年12月10日
1171120570 LV1
2020年12月18日
zuiwomengjiaren LV11
2020年9月4日
zhengshuang LV1
2020年5月31日
vpv123
2020年3月7日
暂无贡献等级
Jay1109 LV1
2019年12月11日
Lee9527 LV1
2019年9月12日
dd168168
2019年8月26日
暂无贡献等级
zxx521125 LV9
2019年8月26日