scorepk.java

来自「Hibernate的精典实例」· Java 代码 · 共 72 行

JAVA
72
字号
package hibernate.demo.compositeKey;

import java.io.Serializable;

/**
 * 复合主键类
 * 
 * @author Administrator
 * 
 */
public class ScorePK implements Serializable {
	private Integer stu_id;

	private Integer sc_id;

	public ScorePK() {

	}

	public ScorePK(Integer stu_id, Integer sc_id) {
		super();
		this.stu_id = stu_id;
		this.sc_id = sc_id;
	}

	public Integer getSc_id() {
		return sc_id;
	}

	public void setSc_id(Integer sc_id) {
		this.sc_id = sc_id;
	}

	public Integer getStu_id() {
		return stu_id;
	}

	public void setStu_id(Integer stu_id) {
		this.stu_id = stu_id;
	}

	public int hashCode() {
		final int PRIME = 31;
		int result = 1;
		result = PRIME * result + ((sc_id == null) ? 0 : sc_id.hashCode());
		result = PRIME * result + ((stu_id == null) ? 0 : stu_id.hashCode());
		return result;
	}

	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final ScorePK other = (ScorePK) obj;
		if (sc_id == null) {
			if (other.sc_id != null)
				return false;
		} else if (!sc_id.equals(other.sc_id))
			return false;
		if (stu_id == null) {
			if (other.stu_id != null)
				return false;
		} else if (!stu_id.equals(other.stu_id))
			return false;
		return true;
	}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?