Although probably a trivial question, I've always wondered about this.
Usually, after insertion into the db, it seems common practice to return the id of the business entity.
@Override
public Long createUser(UserEntity user) {
em.merge(user);
em.flush();
return user.getId();
}
Is there a convincing reason for returning the id instead of the business object reference itself?
Similarly, I've seen update
return void
, while it might just as well be an id / User.
If I were to write a DAO / Repository for others to use, what would be the advised return value (if any), and why?
Aucun commentaire:
Enregistrer un commentaire