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;
I have linked the Posts
model with the Privacy_Level
model using a
manytoone/onetomany relationship while the Table_Status
model with Privacy_Level
model using a many to one/one to many relationship as well.
Now I need to access a value in Table_Status
through a Posts
object as shown below:
post.privacy_level_t.table_status.getDes()
This worked fine in Play 2.5 but after migrating to Play 2.6 this returns a null value.
I can however access a Privacy_Level
value using post.privacy_level_t.getDes()
but
trying to access a value one step further down the hierarchy line returns an error.
I checked through the Play migration guide but could not find anything related to this issue.
UPDATE
This is the function that i'm having the mentioned issue.
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;
}
The code inside the if condition returns a NullPointerException in Play 2.6