FIX: Create-drop databse. Add ManyToMany annotation
This commit is contained in:
@@ -4,14 +4,8 @@ import greenify.common.ApplicationException;
|
|||||||
import greenify.server.Application;
|
import greenify.server.Application;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
import javax.persistence.*;
|
||||||
import java.util.Objects;
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.GeneratedValue;
|
|
||||||
import javax.persistence.GenerationType;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
import javax.persistence.Table;
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@@ -20,7 +14,9 @@ import javax.validation.constraints.NotNull;
|
|||||||
public class User {
|
public class User {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
@NotNull
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
|
// @Column(name = "id")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -31,7 +27,12 @@ public class User {
|
|||||||
|
|
||||||
private int veganMeal;
|
private int veganMeal;
|
||||||
|
|
||||||
private ArrayList<User> friends;
|
// @ElementCollection
|
||||||
|
// @CollectionTable(name = "friends", joinColumns = @JoinColumn(name = "id"))
|
||||||
|
// @Column(name = "friendId")
|
||||||
|
@ManyToMany
|
||||||
|
@JoinColumn
|
||||||
|
private Collection<User> friends;
|
||||||
|
|
||||||
public User() {}
|
public User() {}
|
||||||
|
|
||||||
@@ -98,8 +99,8 @@ public class User {
|
|||||||
this.veganMeal = veganMeal;
|
this.veganMeal = veganMeal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<User> getFriends(){
|
public ArrayList<User> getFriends(){
|
||||||
return this.friends;
|
return (ArrayList<User>)this.friends;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addFriend(User user){
|
public void addFriend(User user){
|
||||||
|
|||||||
Reference in New Issue
Block a user