/* * Copyright 2002-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.github.yingzhuo.mycar.domain; import java.io.Serializable; import java.util.Date; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.EntityListeners; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import org.springframework.data.annotation.CreatedBy; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.LastModifiedBy; import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; /** * 联系人 * * @author 应卓 * */ @Entity @Table(name = "TBL_CONTACT") @EntityListeners({ AuditingEntityListener.class }) public class Contact implements Serializable { private static final long serialVersionUID = 8537526593409299095L; private Integer id; private String name; private String title; private String address; private String phoneNumbers; @CreatedBy private User owner; @CreatedDate private Date createdDate; @LastModifiedBy private User lastModifier; @LastModifiedDate private Date lastModifiedTime; // ----------------------------------------------------------------------------------------------- public Contact() { super(); } // ----------------------------------------------------------------------------------------------- @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((id == null) ? 0 : id.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof Contact)) return false; Contact other = (Contact) obj; if (id == null) { if (other.id != null) return false; } else if (!id.equals(other.id)) return false; return true; } @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE) .append(this.id) .append(this.name) .append(this.phoneNumbers) .append(this.address) .append(this.title) .build(); } // ----------------------------------------------------------------------------------------------- @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "CONTACT_ID") public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } @Column(name = "CONTACT_TITLE") public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } @Column(name = "CONTACT_NAME") public String getName() { return name; } public void setName(String name) { this.name = name; } @Column(name = "CONTACT_ADDRESS") public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } @Column(name = "CONTACT_PHONE_NUMBERS") public String getPhoneNumbers() { return phoneNumbers; } public void setPhoneNumbers(String phoneNumbers) { this.phoneNumbers = phoneNumbers; } @ManyToOne @JoinColumn(name = "CONTACT_OWNER_ID") public User getOwner() { return owner; } public void setOwner(User owner) { this.owner = owner; } @Temporal(TemporalType.TIMESTAMP) @Column(name = "CONTACT_CREATED_DATE") public Date getCreatedDate() { return createdDate; } public void setCreatedDate(Date createdDate) { this.createdDate = createdDate; } @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "CONTACT_LAST_MODIFIED_BY") public User getLastModifier() { return lastModifier; } public void setLastModifier(User lastModifier) { this.lastModifier = lastModifier; } @Temporal(TemporalType.TIMESTAMP) @Column(name = "CONTACT_LAST_MODIFIED_TIME") public Date getLastModifiedTime() { return lastModifiedTime; } public void setLastModifiedTime(Date lastModifiedTime) { this.lastModifiedTime = lastModifiedTime; } }