vendredi 20 mars 2015

Objectify v5: Profile is not a supported property type



I've been following Objectify's v5 tutorial and I have two classes where one is embedded in the other:



@Entity
public class User {

@Id Long id;

private Profile profile;

private User(){}

/**
* Creates a new instance of user.
* @param id Id of the user. If <code>null</code>, id will be automatically generated.
* @param profile profile of the user.
*/
public User(final Long id, @NotNull final Profile profile){

this.id = id;
this.profile = profile;

}
}
public class Profile {

private String firstName;

private String middleName;

private String lastName;

private Date birthDate;

private Profile(){}

public Profile(@NotNull final String firstName, @NotNull final String lastName ){

this.firstName = firstName;
this.lastName = lastName;

}
}


In order to test this code, I wrote the following endpoint:



@ApiMethod(name = "user.create", httpMethod = "post")
public User createUser(@Named("id") Long id, @Named("fn") String firstName, @Named("ln") String lastName){

Profile profile = new Profile(firstName,lastName);
User user = new User(id,profile);

ofy().save().entity(user).now();

return user;
}


but when I perform this request, I get an error:



Profile is not a supported property type.



I don't understand why I'm facing this problem because, as far as I can tell, my case is similar to the Car/Engine example given in the tutorial.


Thanks for your help.




Aucun commentaire:

Enregistrer un commentaire