I am using Play framework with Ebean. I have two models, below are the code:
public class User extends Model {
@Id
public Long id;
public String name;
/* rest of attributes */
public static Finder<Long,User> find = new Finder<Long,User>(
Long.class, User.class
);
}
public class Admin extends Model {
@Id
public Long id;
@OneToOne
public User user;
/* rest of attributes */
public static Finder<Long,Admin> find = new Finder<Long,Admin>(
Long.class, Admin.class
);
}
When I do Logger.info(admin.user.name) in Java, I can see the name of the admin. But when I pass the Java object to Scala using view render, if I do @admin.user.id, I can still get the id, but if I do @admin.user.name, I get nothing (with no error). I’m just wonder how can I access the name attribute from a joined table?
Problem solved.
Before when I do the fetching, I did
After changing to
It successfully displayed instance variables on Scala.