Here is the deal I have a one to many relationship between User and Post
@Entity
public class User extends Model {
...
@OneToMany(cascade = CascadeType.ALL, targetEntity = Post.class, mappedBy = "author")
@OrderBy("createdAt DESC")
public List<Post> posts;
...
}
@Entity
public class Post extends Model {
...
public int privacy; // 0=public, 1=private
@ManyToOne
public User author;
...
}
Works beautifully… Now I want to retrieve the public posts from the users? Of course iterating over the result and deleting the private posts is not an option, I ultimately need to do some pagination, and that would become a headache. Is there some annotation that could help me out with that?
Something like this ?