How to add @Expose to an id model without rewriting the original id?
Using GSon, I'd like to show the id of my model when transforming it to JSON. But I don't want all my model to have the id exposed.
Do I have to rewrite the id line of the class Model from PlayFramework in my current Model, something like :
class Account extends Model开发者_开发问答 {
@Id
@GeneratedValue
@Expose
public Long id;
@Expose
public String email;
public String password;
}
Or is there a better way?
Thanks for your help.
Check out the GenericModel
. Model
has a generated ID, GenericModel
hasn't. Meaning you can extends GenericModel
to create whatever ID you want and expose it if you want.
精彩评论