From: Roland Häder <roland@mxchange.org>
Date: Wed, 20 Sep 2017 18:37:12 +0000 (+0200)
Subject: Continued:
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4c3aa667fcaf4c892707a3b31048ad06c625e802;p=jcontacts-business-core.git

Continued:
- need to have serial number unique accross project's JARs
- added named query SearchBranchOfficeById which searches for branch office
  entity by it's primary key

Signed-off-by: Roland Häder <roland@mxchange.org>
---

diff --git a/src/org/mxchange/jcontactsbusiness/exceptions/basicdata/BasicCompanyDataNotFoundException.java b/src/org/mxchange/jcontactsbusiness/exceptions/basicdata/BasicCompanyDataNotFoundException.java
index fc7df97..8f214c9 100644
--- a/src/org/mxchange/jcontactsbusiness/exceptions/basicdata/BasicCompanyDataNotFoundException.java
+++ b/src/org/mxchange/jcontactsbusiness/exceptions/basicdata/BasicCompanyDataNotFoundException.java
@@ -19,7 +19,7 @@ package org.mxchange.jcontactsbusiness.exceptions.basicdata;
 import java.text.MessageFormat;
 
 /**
- * An exception thrown when a contact (entity) has not found.
+ * An exception thrown when basic company data (entity) has not found.
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
@@ -28,7 +28,7 @@ public class BasicCompanyDataNotFoundException extends Exception {
 	/**
 	 * Serial number
 	 */
-	private static final long serialVersionUID = 23_759_801_876_416_568L;
+	private static final long serialVersionUID = 23_759_801_876_416_569L;
 
 	/**
 	 * Constructor with business contact id
diff --git a/src/org/mxchange/jcontactsbusiness/exceptions/branchoffice/BranchOfficeNotFoundException.java b/src/org/mxchange/jcontactsbusiness/exceptions/branchoffice/BranchOfficeNotFoundException.java
new file mode 100644
index 0000000..5ee8a4a
--- /dev/null
+++ b/src/org/mxchange/jcontactsbusiness/exceptions/branchoffice/BranchOfficeNotFoundException.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2016, 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcontactsbusiness.exceptions.branchoffice;
+
+import java.text.MessageFormat;
+
+/**
+ * An exception thrown when a branch office (entity) has not found.
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class BranchOfficeNotFoundException extends Exception {
+
+	/**
+	 * Serial number
+	 */
+	private static final long serialVersionUID = 23_759_801_876_416_570L;
+
+	/**
+	 * Constructor with branch office id
+	 * <p>
+	 * @param branchOfficeId Branch office id
+	 */
+	public BranchOfficeNotFoundException (final Long branchOfficeId) {
+		// Call super constructor with message and cause
+		super(MessageFormat.format("Branch office with id {0} was not found.", branchOfficeId)); //NOI18N
+	}
+
+	/**
+	 * Constructor with branch office id and causing exception
+	 * <p>
+	 * @param branchOfficeId Branch office id
+	 * @param cause          Causing exception
+	 */
+	public BranchOfficeNotFoundException (final Long branchOfficeId, final Throwable cause) {
+		// Call super constructor with message and cause
+		super(MessageFormat.format("Branch office with id {0} was not found.", branchOfficeId), cause); //NOI18N
+	}
+
+	/**
+	 * Constructor with email address and causing exception
+	 * <p>
+	 * @param emailAddress Email address
+	 * @param cause        Causing exception
+	 */
+	public BranchOfficeNotFoundException (final String emailAddress, final Throwable cause) {
+		// Call super constructor with message and cause
+		super(MessageFormat.format("Branch office with email address {0} was not found.", emailAddress), cause); //NOI18N
+	}
+
+}
diff --git a/src/org/mxchange/jcontactsbusiness/exceptions/employee/CompanyEmployeeNotFoundException.java b/src/org/mxchange/jcontactsbusiness/exceptions/employee/CompanyEmployeeNotFoundException.java
index 6e44956..21ee750 100644
--- a/src/org/mxchange/jcontactsbusiness/exceptions/employee/CompanyEmployeeNotFoundException.java
+++ b/src/org/mxchange/jcontactsbusiness/exceptions/employee/CompanyEmployeeNotFoundException.java
@@ -28,7 +28,7 @@ public class CompanyEmployeeNotFoundException extends Exception {
 	/**
 	 * Serial number
 	 */
-	private static final long serialVersionUID = 23_759_801_876_416_568L;
+	private static final long serialVersionUID = 23_759_801_876_416_571L;
 
 	/**
 	 * Constructor with company employee id
diff --git a/src/org/mxchange/jcontactsbusiness/exceptions/headquarters/CompanyHeadquartersNotFoundException.java b/src/org/mxchange/jcontactsbusiness/exceptions/headquarters/CompanyHeadquartersNotFoundException.java
index ce1799c..738dd6e 100644
--- a/src/org/mxchange/jcontactsbusiness/exceptions/headquarters/CompanyHeadquartersNotFoundException.java
+++ b/src/org/mxchange/jcontactsbusiness/exceptions/headquarters/CompanyHeadquartersNotFoundException.java
@@ -28,7 +28,7 @@ public class CompanyHeadquartersNotFoundException extends Exception {
 	/**
 	 * Serial number
 	 */
-	private static final long serialVersionUID = 23_759_801_876_416_568L;
+	private static final long serialVersionUID = 23_759_801_876_416_572L;
 
 	/**
 	 * Constructor with company headquarters id
diff --git a/src/org/mxchange/jcontactsbusiness/model/branchoffice/CompanyBranchOffice.java b/src/org/mxchange/jcontactsbusiness/model/branchoffice/CompanyBranchOffice.java
index ee57cb5..4a855a8 100644
--- a/src/org/mxchange/jcontactsbusiness/model/branchoffice/CompanyBranchOffice.java
+++ b/src/org/mxchange/jcontactsbusiness/model/branchoffice/CompanyBranchOffice.java
@@ -54,9 +54,12 @@ import org.mxchange.jusercore.model.user.User;
  */
 @Entity (name = "company_branch_offices")
 @Table (name = "company_branch_offices")
-@NamedQueries ({
-	@NamedQuery (name = "AllBranchOffices", query = "SELECT bo FROM company_branch_offices AS bo ORDER BY bo.branchId ASC")
-})
+@NamedQueries (
+		{
+			@NamedQuery (name = "AllBranchOffices", query = "SELECT bo FROM company_branch_offices AS bo ORDER BY bo.branchId ASC"),
+			@NamedQuery (name = "SearchBranchOfficeById", query = "SELECT bo FROM company_branch_offices AS bo WHERE bo.branchId = :branchOfficeId")
+		}
+)
 @SuppressWarnings ("PersistenceUnitPresent")
 public class CompanyBranchOffice implements BranchOffice {
 
@@ -180,11 +183,11 @@ public class CompanyBranchOffice implements BranchOffice {
 	 * Constructor with all required fields. This constructor may throw
 	 * exceptions when one parameter is not valid or NULL.
 	 * <p>
-	 * @param branchCity         Branch office's city
-	 * @param branchCompany      Branch office's assigned company
-	 * @param branchCountry      Branch office's country
-	 * @param branchStreet       Branch office's street
-	 * @param branchZipCode      Branch office's ZIP code
+	 * @param branchCity        Branch office's city
+	 * @param branchCompany     Branch office's assigned company
+	 * @param branchCountry     Branch office's country
+	 * @param branchStreet      Branch office's street
+	 * @param branchZipCode     Branch office's ZIP code
 	 * @param branchHouseNumber Branch office's house number
 	 */
 	public CompanyBranchOffice (final String branchCity, final BusinessBasicData branchCompany, final Country branchCountry, final String branchStreet, final Integer branchZipCode, final Short branchHouseNumber) {