---
# System prepended metadata

title: Hibernate 24頁
tags: [hibernate]

---

# Hibernate 24頁
###### tags: `hibernate`

## 24頁
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.Table;
    import javax.persistence.Transient;
    import javax.persistence.UniqueConstraint;

    @Entity
    @Table(
		name="Member_Table_EEIT126",
		uniqueConstraints= {
				@UniqueConstraint(columnNames= {"employee_Id","empName"}),
				@UniqueConstraint(columnNames= {"pswd"})
		})
        
    @Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	Integer pk;
	@Column(name="employee_id")
	String id;
	String pswd;
	String name;
	@Column(columnDefinition = "DECIMAL(5,1)")
	Double Score;
    
    
``` click=
package ch01.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;

@Entity
@Table(name="Member_Table_EEIT126",
uniqueConstraints= {
					@UniqueConstraint(columnNames={"employee_ID","empName"}),
					@UniqueConstraint(columnNames={"pswd"})
					})
public class MemberBean {
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	Integer pk;
	@Column(name="employee_mid")
	String id;
	
	String pswd;
	
	@Transient String pswd2;
	
	String name;
	
	public String getPswd2() {
		return pswd2;
	}
	public void setPswd2(String pswd2) {
		this.pswd2 = pswd2;
	}
	@Column(columnDefinition = "DECIMAL(5,1)")//總長4 長度5 小數點1位
	//@Transient 不想要存到
	//transient //短暫瞬間臨時的
	Double score;
	
	public MemberBean() {
		super();
	}
	public MemberBean(String id, String pswd, String name) {
		super();
		this.id = id;
		this.pswd = pswd;
		this.name = name;
	}
	
	public MemberBean(Integer pk, String id, String pswd, String name) {
		super();
		this.pk = pk;
		this.id = id;
		this.pswd = pswd;
		this.name = name;
	}
	public MemberBean(Integer ipk) {
		this.pk = ipk;
	}
	public int getPk() {
		return pk;
	}
	public void setPk(Integer pk) {
		this.pk = pk;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getPswd() {
		return pswd;
	}
	public Double getScore() {
		return score;
	}
	public void setScore(Double score) {
		this.score = score;
	}
	public void setPswd(String pswd) {
		this.pswd = pswd;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
}

```