Skip to content

Instantly share code, notes, and snippets.

@PreSoichiSumi
Created May 29, 2016 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PreSoichiSumi/fe9955a24008eea82aa5cde377776b8b to your computer and use it in GitHub Desktop.
Save PreSoichiSumi/fe9955a24008eea82aa5cde377776b8b to your computer and use it in GitHub Desktop.
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