1
votes

I have two classes :

public class Tag {
@Id
public int id;

@ManyToMany(cascade=CascadeType.ALL)
public static List<Article> articles;

public static Finder<Long, Tag> find = new Finder<Long, Tag>(Long.class, Tag.class);
}


public class Article {  
@Id
public int id;

@Constraints.Required
public String title;

@ManyToMany(cascade=CascadeType.ALL)
public static List<Tag> tags;

public static Finder<Long, Article> find = new Finder<Long, Article>(Long.class,     Article.class);

I need function that gain article as parameter and give back list of tags, related to this article

1
there is a } missing at the end of the second class. Besides: have you tried something? - Francesco Montesano

1 Answers

0
votes

Try this:

public List<Tag> findTagsByArticle(Article article) {
    return find.fetch("articles").where().eq("articles.id", article.id).findList();     
}

Check similar question with answer

filterMany() is described in its API