Created
May 29, 2016 21:33
-
-
Save PreSoichiSumi/fe9955a24008eea82aa5cde377776b8b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package models; | |
import com.avaje.ebean.annotation.CreatedTimestamp; | |
import javax.persistence.*; | |
import java.io.Serializable; | |
import java.util.Date; | |
@Embeddable | |
public class CombinedTweetKey implements Serializable{ | |
@Id | |
@GeneratedValue(strategy = GenerationType.AUTO) | |
@Column(name = "tweet_id",nullable = false) | |
public Long tweetId; | |
@Column(name = "post_date",nullable = false) | |
@CreatedTimestamp | |
public Date postDate; | |
public Long getTweetId() { | |
return tweetId; | |
} | |
public void setTweetId(Long tweetId) { | |
this.tweetId = tweetId; | |
} | |
public Date getPostDate() { | |
return postDate; | |
} | |
public void setPostDate(Date postDate) { | |
this.postDate = postDate; | |
} | |
/** | |
* 複合キーなら必ずoverrideする必要あり | |
* @param o | |
* @return | |
*/ | |
@Override | |
public boolean equals(Object o) { | |
if (this == o) return true; | |
if (o == null || getClass() != o.getClass()) return false; | |
CombinedTweetKey that = (CombinedTweetKey) o; | |
if (!tweetId.equals(that.tweetId)) return false; | |
return postDate.equals(that.postDate); | |
} | |
@Override | |
public int hashCode() { | |
int result = tweetId.hashCode(); | |
result = 31 * result + postDate.hashCode(); | |
return result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment