Posts Model
/*set many to one relation with Privacy_Level model*/
@ManyToOne//(fetch = FetchType.LAZY)
@JoinColumn(name = "privacy_level_id",referencedColumnName = "id", insertable = false, updatable = false)
public Privacy_Level privacy_level_t;
-------------------------------------------------------------------------------------------------------------
Privacy_Level Model
/*set one to many relation with Posts model*/
@OneToMany(mappedBy = "privacy_level_t")
public List<Posts> posts;
/*set many to one relation with Table_Status model*/
@ManyToOne
@JoinColumn(name = "status",referencedColumnName = "id", insertable = false, updatable = false)
public Table_Status table_status;
--------------------------------------------------------------------------------------------------------------
Table_Status Model
/*set many to one relation with Privacy_level table*/
@OneToMany(mappedBy = "table_status")
public List<Privacy_Level> privacy_level;
我已将Posts
模型与Privacy_Level
模型链接在一起,
Table_Status
模型与Privacy_Level
时的多对一/单调关系
模型也使用多对一/一对多关系。
现在,我需要通过Table_Status
对象访问Posts
中的值,如下所示:
post.privacy_level_t.table_status.getDes()
这在Play 2.5中工作正常,但是在迁移到Play 2.6后,这将返回空值。
但是,我可以使用Privacy_Level
访问一个post.privacy_level_t.getDes()
值,但是
尝试在层次结构行的下一级访问值将返回错误。
我检查了Play迁移指南,但找不到与此相关的任何内容 问题。
更新
这是我遇到的问题。
private boolean getPostsDetail(List<Posts> post_list){
home_page_posts = Json.newArray();
for(Posts post:post_list) {
if(!post.privacy_level_t.table_status.getDes().equals("activated")) continue;
switch (post.post_types.getPost_type_name()){
case "Star_Rating":
getArrayNodeForNonAnonyStarPost(post);
continue;
case "Text_Poll":
getArrayNodeForNonAnonyPollPost(post);
continue;
case "Image_Poll":
getArrayNodeForNonAnonyPollPost(post);
continue;
case "star_rating_post_other_detail":
getArrayNodeForAnonyStarPost(post);
continue;
default:
continue;
}
}
return true;
}
if条件中的代码在Play 2.6中返回NullPointerException