return addressbook;
}
+ @Override
+ public boolean isAddressbookIdUsed (final Long addressbookId) {
+ // Is it null or zero?
+ if (null == addressbookId) {
+ // Throw NPE
+ throw new NullPointerException("addressbookId is null"); //NOI18N
+ } else if (addressbookId < 1) {
+ // Not valid id number
+ throw new IllegalArgumentException(MessageFormat.format("addressbookId is not valid: {0}", addressbookId)); //NOI18N
+ }
+
+ // Get query instance
+ Query query = this.getEntityManager().createNamedQuery("FindAddressbookById");
+
+ // Set parameter
+ query.setParameter("id", addressbookId);
+
+ // Default is not valid
+ boolean isValid = false;
+
+ // Try it again, yes no other way
+ try {
+ // Get single result
+ Addressbook addressbook = (Addressbook) query.getSingleResult();
+
+ // Found one!
+ isValid = true;
+ } catch (final NoResultException ex) {
+ // Debug log only, maybe out-dated link followed
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("isAddressbookIdUsed: addressbookId={0} is not valid: {1}", addressbookId, ex));
+ }
+
+ // Return result
+ return isValid;
+ }
+
@Override
public boolean isAddressbookNameUsed (final Addressbook addressbook) {
// Is it not null?
isUsed = true;
} catch (final NoResultException ex) {
// No result found, so log it away
- this.getLoggerBeanLocal().logDebug("isAddressbookNameUsed: getSingleResult() did not return a result: " + ex); //NOI18N
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("isAddressbookNameUsed: getSingleResult() did not return a result: {0}", ex)); //NOI18N //NOI18N
}
// Return result