1

これは私のトピックのデータメンバーです:

public class Topic extends Model {  
@Id  
protected long id;  
public String title;  
public String content;  
@ManyToOne  
@JoinColumn(name = "forumId")  
public Forum forum;  // this is a reference to the topic's forum. 

postgresqlにbigint(フォーラムクラスのID)として保存されたフォーラム属性

これは私のトピックのファインダーです:

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

今、私はFinderを使用して最も簡単なことを試みています。フォーラムIDでトピックを取得します。
私は多くのバリエーションを試しましたが、これはそのうちの1つです。

public static List<Topic> getTopicsByForum(long id) {
    Forum forum = Forum.getById(id);
    return find.where().gt("forumId", forum).findList();
}

間違った結果が出ます。私は何か間違ったことをしなければなりませんが、何がわかりません。

4

1 に答える 1

1

Ebeanを使用すると、プロパティに直接アクセスできるため、次のことを試してください。

public static List<Topic> getTopicsByForum(Long forumId) {
    return find.where().eq("forum.id", forumId).findList();
}
于 2012-08-17T13:30:23.687 に答える