[jdf-users] [jdf] Re: JBoss Developer Framework

Disqus notifications at disqus.net
Sun Feb 17 17:59:17 EST 2013



mick <nik473-forum at 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%2Fquickstarts%2Fjboss-as-quickstart%2Fguide%2FGreeterQuickstart%2F%23comment-801701513%3A6lbQ1LilVki7-rVuvTd6iIZFbqQ&impression=a7e3e068-7955-11e2-a75e-003048df93b0&type=notification.post.moderator&event=email&behavior=click

-----
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jdf-users/attachments/20130217/9b06a7b7/attachment.html 


More information about the jdf-users mailing list