Thank you for this very instructive tutorial.
But there is a little mistake in Method "getForUsername", because
the finally block executes commit() even in the case of an exception.
Please correct this part to:
public User getForUsername(String username) {
try {
User user;
try {
utx.begin();
Query query = entityManager.createQuery("select u from User u where u.username = ?");
query.setParameter(1, username);
user = (User) query.getSingleResult();
} catch (NoResultException e) {
user = null;
}
utx.commit();
return user;
} catch (Exception e) { ...
The Method greet() should catch the Exception thrown in getForUsername:
public vo...
-----
Options: You can moderate through email. Respond in the body with "Delete", "Approve", or "Spam". Reply with "Like" to like this comment, or respond in the body to post a reply comment.
Or use the moderate panel: http://jdf.disqus.com/admin/moderate/#/pending