close connection before throwing an exception
This commit is contained in:
parent
7ae9e3ee22
commit
871df4f918
@ -24,6 +24,7 @@ public class CommandServiceImpl implements ICommandService {
|
|||||||
author = (Author) query.uniqueResult();
|
author = (Author) query.uniqueResult();
|
||||||
}
|
}
|
||||||
if (author == null) {
|
if (author == null) {
|
||||||
|
HibernateUtil.getSessionFactory().close();
|
||||||
throw new NullPointerException("Author " + username + " doesn't exist!");
|
throw new NullPointerException("Author " + username + " doesn't exist!");
|
||||||
}
|
}
|
||||||
return author;
|
return author;
|
||||||
@ -37,6 +38,7 @@ public class CommandServiceImpl implements ICommandService {
|
|||||||
book = (Book) query.uniqueResult();
|
book = (Book) query.uniqueResult();
|
||||||
}
|
}
|
||||||
if (book == null) {
|
if (book == null) {
|
||||||
|
HibernateUtil.getSessionFactory().close();
|
||||||
throw new NullPointerException("Book " + title + " doesn't exist!");
|
throw new NullPointerException("Book " + title + " doesn't exist!");
|
||||||
}
|
}
|
||||||
return book;
|
return book;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user