Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 奇怪的结果_Java_Database_Playframework 2.0_Ebean - Fatal编程技术网

Java 奇怪的结果

Java 奇怪的结果,java,database,playframework-2.0,ebean,Java,Database,Playframework 2.0,Ebean,这是我的主题的数据成员: 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. 论坛属性保存在postg

这是我的主题的数据成员:

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);
publicstaticfinder=newfinder(Long.class,Topic.class);
现在,我正在使用Finder尝试最简单的方法。按论坛id检索主题。
我尝试了许多变体,这是其中之一:

public static List<Topic> getTopicsByForum(long id) {
    Forum forum = Forum.getById(id);
    return find.where().gt("forumId", forum).findList();
}
公共静态列表getTopicsByForum(长id){
Forum Forum=Forum.getById(id);
返回find.where().gt(“forumId”,forum.findList();
}

我得到了错误的结果。我一定是做错了什么,但不知道是什么。

使用Ebean,您可以直接访问属性,因此请尝试以下操作:

public static List<Topic> getTopicsByForum(Long forumId) {
    return find.where().eq("forum.id", forumId).findList();
}
公共静态列表getTopicsByForum(Long-forumId){
返回find.where().eq(“forum.id”,forumId).findList();
}

使用Ebean,您可以直接访问属性,因此请尝试以下操作:

public static List<Topic> getTopicsByForum(Long forumId) {
    return find.where().eq("forum.id", forumId).findList();
}
公共静态列表getTopicsByForum(Long-forumId){
返回find.where().eq(“forum.id”,forumId).findList();
}

好的,它可以工作。但是我需要将属性名从“forumId.id”改为“forum.id”;它必须是属性名(而不是列名)。好的,它可以工作。但是我需要将属性名从“forumId.id”改为“forum.id”;它必须是属性名(而不是列名)。