Please let me see your post entity and person entity classes to see whether i can resolve this for you.
package com.example.demo.model;
import javax.persistence.*; import javax.persistence.OneToMany; import java.util.Collection; import java.util.Date; import java.util.List;
@Entity public class Post { public long getId() { return id; }
public void setId(long id) { this.id = id; } public void setTitle(String title) { this.title = title; } public void setBody(String body) { this.body = body; } public void setCreatedDate(Date createdDate) { this.createdDate = createdDate; } public String getTitle() { return title; } public String getBody() { return body; } public Date getCreatedDate() { return createdDate; } @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id; private String title; private String body; private Date createdDate; public List<Comment> getComments() { return comments; } public void setComments(List<Comment> comments) { this.comments = comments; } @OneToMany(mappedBy = "post", cascade = CascadeType.REMOVE) private List<Comment>comments;
}
import javax.persistence.*; import java.util.Collection; @Table @Entity public class Person { @id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; private String username; public String getEmail() { return email; }
public void setEmail(String email) { this.email = email; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } private String email; private String password; public Person() { } public Person(String name) { this.username = name; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getName() { return username; } public void setName(String name) { this.username = name; }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Please let me see your post entity and person entity classes to see whether i can resolve this for you.
package com.example.demo.model;
import javax.persistence.*;
import javax.persistence.OneToMany;
import java.util.Collection;
import java.util.Date;
import java.util.List;
@Entity
public class Post {
public long getId() {
return id;
}
}
package com.example.demo.model;
import javax.persistence.*;
import java.util.Collection;
@Table
@Entity
public class Person {
@id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String username;
public String getEmail() {
return email;
}
}