I'd like to use UUID instead of the regular id on my models.
Can this be done with the play framework?
First don`t extend (play.db.jpa.Model) Model in the Model you want to generate the Id but use GenericModel.
then you could use helper class that called when object is created (in constructor).
or call the helper class when saved(thus i have to create wrapper DAO, the save process is done in wrapper DAO not in the Object so that i could generate id the save the object)
or if you want more simple approach use JPA UUID. See code below.
@Entity
public class User extends GenericModel {
@Id
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")
public String id;
}
GenericModel: isn't it a anti pattern? please see: en.wikipedia.org/wiki/BaseBean
see the comment on the wiki and the neutrality of the wiki that say "The neutrality of this article is disputed" so called this anti-pattern in inappropriate.