別のオブジェクト内にあるオブジェクト内にあるフィールドを取得するのに問題があります。いくつかのフィールドを取得できますが、他のフィールドは取得できません。
これは、このエラーを再現するために作成したテストです。
public void commentTest(){
try {
new MyUser("mauri@mail.com","Maurizio Pozzobon","01","facebook","hash").insert();
} catch (Exception e) {}
MyUser user = MyUser.findByEmail("mauri@mail.com");
Place place = new Place(user,"posto","bel posto",null,null);
place.insert();
assertNotNull(user);
Event e =new Event(user,place, "Festa","Questa è una gran bella festa",null,new Date(),(long) 10,false,null);
e.insert();
assertNotNull(user.nome);
EventComment ec = new EventComment(user, e, "TestComment", new Date());
ec.insert();
List<EventComment> ecs = e.comments.fetch();
for (EventComment comment : ecs) {
assertNotNull(comment.user.id);
MyUser us= MyUser.findById(comment.user.id);
assertNotNull(us.nome);
assertNotNull(comment.user.nome);
}
}
ラインで失敗する
assertNotNull(comment.user.nome);
DBへの他の呼び出しを行ってそのフィールドに到達できるので、これは契約違反ではありませんが、一部のフィールドにアクセスでき、他のフィールドにアクセスできないのは奇妙に思えます
MyUser で、次の注釈を付けて、または付けずに「nome」フィールドを宣言しようとしました
@Column("nome")
@Max(200) @NotNull
public String nome;