FIX: Create-drop databse. Add ManyToMany annotation
This commit is contained in:
@@ -13,6 +13,8 @@ import javax.persistence.GeneratedValue;
|
|||||||
import javax.persistence.GenerationType;
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
import java.util.*;
|
||||||
|
import javax.persistence.*;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@@ -21,7 +23,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
|
||||||
@@ -36,6 +40,10 @@ public class User {
|
|||||||
@ElementCollection
|
@ElementCollection
|
||||||
private Map<String,String> footPrintInputs = new HashMap<>();
|
private Map<String,String> footPrintInputs = new HashMap<>();
|
||||||
|
|
||||||
|
@ManyToMany
|
||||||
|
@JoinColumn
|
||||||
|
private Collection<User> friends;
|
||||||
|
|
||||||
public User() {}
|
public User() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -103,6 +111,10 @@ public class User {
|
|||||||
this.footPrintInputs = footPrintInputs;
|
this.footPrintInputs = footPrintInputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<User> getFriends(){
|
||||||
|
return (ArrayList<User>)this.friends;
|
||||||
|
}
|
||||||
|
|
||||||
public void setFootPrint(Float footPrint) {
|
public void setFootPrint(Float footPrint) {
|
||||||
this.footPrint = footPrint;
|
this.footPrint = footPrint;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user