Merge pull request #161 from Doha2012/master

modify post and user models
This commit is contained in:
Eugen 2015-03-10 23:51:16 +02:00
commit 5199880d3d
2 changed files with 8 additions and 14 deletions

View File

@ -2,6 +2,7 @@ package org.baeldung.persistence.model;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
@ -16,14 +17,18 @@ public class Post {
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(nullable = false)
private String title;
@Column(nullable = false)
private String subreddit;
@Column(nullable = false)
private String url;
private boolean sendReplies;
@Column(nullable = false)
private Date submissionDate;
private boolean isSent;
@ -31,7 +36,7 @@ public class Post {
private String submissionResponse;
@ManyToOne
@JoinColumn(name = "user_id")
@JoinColumn(name = "user_id", nullable = false)
private User user;
public Post() {

View File

@ -1,13 +1,12 @@
package org.baeldung.persistence.model;
import java.util.Date;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
@Entity
public class User {
@ -16,6 +15,7 @@ public class User {
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(nullable = false)
private String username;
private String accessToken;
@ -26,9 +26,6 @@ public class User {
private boolean needCaptcha;
@OneToMany(mappedBy = "user")
private List<Post> posts;
public User() {
super();
}
@ -81,14 +78,6 @@ public class User {
this.needCaptcha = needCaptcha;
}
public List<Post> getPosts() {
return posts;
}
public void setPosts(List<Post> posts) {
this.posts = posts;
}
@Override
public int hashCode() {
final int prime = 31;