mick <nik473-forum(a)yahoo.de> (unregistered) wrote:
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 void greet() {
try {
...
} catch (Exception e) {
greeting = "Data base problem";
}
}
IP address: 93.128.240.101
Link to comment:
http://redirect.disqus.com/url?url=http%3A%2F%2Fjboss.org%2Fjdf%2Fstage%2...
-----
Options: You can moderate through email. Respond in the body with "Delete".
Reply with "Like" to like this comment, or respond with anything else to approve
this comment and post your message as a reply comment.
Or use the moderate panel:
http://jdf.disqus.com/admin/moderate/#/pending
Stop receiving notifications when new comments are posted:
http://disqus.com/account/#notifications