From 4c3aa667fcaf4c892707a3b31048ad06c625e802 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 20 Sep 2017 20:37:12 +0200 Subject: [PATCH] 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 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../BasicCompanyDataNotFoundException.java | 4 +- .../BranchOfficeNotFoundException.java | 65 +++++++++++++++++++ .../CompanyEmployeeNotFoundException.java | 2 +- .../CompanyHeadquartersNotFoundException.java | 2 +- .../branchoffice/CompanyBranchOffice.java | 19 +++--- 5 files changed, 80 insertions(+), 12 deletions(-) create mode 100644 src/org/mxchange/jcontactsbusiness/exceptions/branchoffice/BranchOfficeNotFoundException.java 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. *

* @author Roland Häder */ @@ -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 . + */ +package org.mxchange.jcontactsbusiness.exceptions.branchoffice; + +import java.text.MessageFormat; + +/** + * An exception thrown when a branch office (entity) has not found. + *

+ * @author Roland Häder + */ +public class BranchOfficeNotFoundException extends Exception { + + /** + * Serial number + */ + private static final long serialVersionUID = 23_759_801_876_416_570L; + + /** + * Constructor with branch office id + *

+ * @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 + *

+ * @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 + *

+ * @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. *

- * @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) { -- 2.39.5