001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.ejb3.test.clusteredentity.embeddedid;
023:
024: import java.io.Serializable;
025:
026: import javax.persistence.Embeddable;
027:
028: /**
029: * Primary key for the {@link Musician} entity.
030: *
031: * @author <a href="brian.stansberry@jboss.com">Brian Stansberry</a>
032: * @version $Revision: 60233 $
033: */
034: @Embeddable
035: public class MusicianPK implements Serializable {
036: private static final long serialVersionUID = 1L;
037:
038: private String firstName;
039: private String lastName;
040: private String ssn;
041:
042: /**
043: * Default constructor
044: */
045: public MusicianPK() {
046: }
047:
048: public MusicianPK(String firstName, String lastName, String ssn) {
049: this .firstName = firstName;
050: this .lastName = lastName;
051: this .ssn = ssn;
052: }
053:
054: public String getFirstName() {
055: return firstName;
056: }
057:
058: public void setFirstName(String firstName) {
059: this .firstName = firstName;
060: }
061:
062: public String getLastName() {
063: return lastName;
064: }
065:
066: public void setLastName(String lastName) {
067: this .lastName = lastName;
068: }
069:
070: public String getSsn() {
071: return ssn;
072: }
073:
074: public void setSsn(String ssn) {
075: this .ssn = ssn;
076: }
077:
078: @Override
079: public boolean equals(Object obj) {
080: boolean equal = (this == obj);
081:
082: if (!equal && obj instanceof MusicianPK) {
083: MusicianPK other = (MusicianPK) obj;
084:
085: equal = firstName.equals(other.firstName)
086: && lastName.equals(other.lastName)
087: && ssn.equals(other.ssn);
088: }
089: return equal;
090: }
091:
092: @Override
093: public int hashCode() {
094: int result = 19;
095: result = result * 29 + firstName.hashCode();
096: result = result * 29 + lastName.hashCode();
097: result = result * 29 + ssn.hashCode();
098: return result;
099: }
100:
101: @Override
102: public String toString() {
103: StringBuffer sb = new StringBuffer(getClass().getName());
104: sb.append("[firstName=");
105: sb.append(firstName);
106: sb.append(",lastName=");
107: sb.append(lastName);
108: sb.append(",ssn=");
109: sb.append(ssn);
110: sb.append("]");
111: return sb.toString();
112: }
113:
114: }
|