联合主键

import java.io.Serializable;

import javax.persistence.Embeddable;

/**
 * The primary key class for the jmoco_user_role_assignment database table.
 * @author lee
 */
@Embeddable
public class PartyRoleAssignmentPk implements Serializable {
	//default serial version id, required for serializable classes.
	private static final long serialVersionUID = 1L;

	private String partyId;

	private String roleId;

	public PartyRoleAssignmentPk() {
	}
	public String getPartyId() {
		return this.partyId;
	}
	public void setPartyId(String partyId) {
		this.partyId = partyId;
	}
	public String getRoleId() {
		return this.roleId;
	}
	public void setRoleId(String roleId) {
		this.roleId = roleId;
	}

	public boolean equals(Object other) {
		if (this == other) {
			return true;
		}
		if (!(other instanceof PartyRoleAssignmentPk)) {
			return false;
		}
		PartyRoleAssignmentPk castOther = (PartyRoleAssignmentPk)other;
		return
			this.partyId.equals(castOther.partyId)
			&& this.roleId.equals(castOther.roleId);
	}

	public int hashCode() {
		final int prime = 31;
		int hash = 17;
		hash = hash * prime + this.partyId.hashCode();
		hash = hash * prime + this.roleId.hashCode();

		return hash;
	}
}
import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MapsId;
import javax.persistence.Table;

import com.lee.mvc.core.user.entity.Role;

/**
 * 
 * @author lee
 */
@Entity
@Table(name = "jmoco_user_role_assignment")
public class PartyRoleAssignment implements Serializable {
	private static final long serialVersionUID = 1L;

	@EmbeddedId
	private PartyRoleAssignmentPk id;

	@Column(name = "flag", columnDefinition = "bit(32) NOT NULL DEFAULT b'1'")
	private int flag = 1;

	public PartyRoleAssignment() {
	}

	public PartyRoleAssignmentPk getId() {
		return id;
	}

	public void setId(PartyRoleAssignmentPk id) {
		this.id = id;
	}

	public int getFlag() {
		return this.flag;
	}

	public void setFlag(int flag) {
		this.flag = flag;
	}

}




你可能感兴趣的:(联合主键)