⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 personkey.java

📁 内容: 本章讲解Hibernate中对数据库复合主键的支持 难度:
💻 JAVA
字号:
/*
 * WARNING: DO NOT EDIT THIS FILE. This is a generated file that is synchronized
 * by MyEclipse Hibernate tool integration.
 *
 * Created Sat Nov 11 21:36:22 CST 2006 by MyEclipse Hibernate Tool.
 */
package org.lxh.hibernate03;

import java.io.Serializable;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

/**
 * A class representing a composite primary key id for the PERSON
 * table.  This object should only be instantiated for use with instances 
 * of the Person class.
 * WARNING: DO NOT EDIT THIS FILE. This is a generated file that is synchronized 
 * by MyEclipse Hibernate tool integration.
 */
public class PersonKey
    implements Serializable
{
    /** The cached hash code value for this instance.  Settting to 0 triggers re-calculation. */
    private volatile int hashValue = 0;

    /** The value of the NAME component of this composite id. */
    private java.lang.String name;

    /** The value of the PHONE component of this composite id. */
    private java.lang.String phone;

    /**
     * Simple constructor of PersonKey instances.
     */
    public PersonKey()
    {
    }

    /**
     * Returns the value of the name property.
     * @return java.lang.String
     */
    public java.lang.String getName()
    {
        return name;
    }

    /**
     * Sets the value of the name property.
     * @param name
     */
    public void setName(java.lang.String name)
    {
        hashValue = 0;
        this.name = name;
    }

    /**
     * Returns the value of the phone property.
     * @return java.lang.String
     */
    public java.lang.String getPhone()
    {
        return phone;
    }

    /**
     * Sets the value of the phone property.
     * @param phone
     */
    public void setPhone(java.lang.String phone)
    {
        hashValue = 0;
        this.phone = phone;
    }

    /**
     * Implementation of the equals comparison on the basis of equality of the id components.
     * @param rhs
     * @return boolean
     */
    public boolean equals(Object obj)
    {
    	if (this == obj) {
			return true;
		}
		if (!(obj instanceof Person)) {
			return false;
		}
		PersonKey p = (PersonKey) obj;
		return new EqualsBuilder().append(this.name, p.getName()).append(this.phone,
				p.getPhone()).isEquals();
    }

    /**
     * Implementation of the hashCode method conforming to the Bloch pattern with
     * the exception of array properties (these are very unlikely primary key types).
     * @return int
     */
    public int hashCode()
    {
    	return new HashCodeBuilder().append(this.name).append(
				this.phone).toHashCode();
    }
}

⌨️ 快捷键说明

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