From 0a19828793f152ea96f148cb6b523c89d7d312a2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 1 Nov 2017 22:50:38 +0100 Subject: [PATCH] Continued: - removed SearchById as this is considered as performance-reducing. The reason is, that the EJB will then be more "asked" for single entries only. - added first named query AllHeadquarters MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../model/basicdata/BusinessBasicData.java | 3 +- .../branchoffice/BusinessBranchOffice.java | 1 - .../model/employee/BusinessEmployee.java | 5 ++- .../headquarters/BusinessHeadquarters.java | 35 +++++++++++-------- .../opening_time/BusinessOpeningTime.java | 1 - 5 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/org/mxchange/jcontactsbusiness/model/basicdata/BusinessBasicData.java b/src/org/mxchange/jcontactsbusiness/model/basicdata/BusinessBasicData.java index d532bfc..88b5fca 100644 --- a/src/org/mxchange/jcontactsbusiness/model/basicdata/BusinessBasicData.java +++ b/src/org/mxchange/jcontactsbusiness/model/basicdata/BusinessBasicData.java @@ -39,6 +39,7 @@ import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; import org.mxchange.jcontactsbusiness.model.employee.BusinessEmployee; import org.mxchange.jcontactsbusiness.model.employee.Employable; import org.mxchange.jcontactsbusiness.model.headquarters.BusinessHeadquarters; +import org.mxchange.jcontactsbusiness.model.headquarters.Headquarter; import org.mxchange.jcontactsbusiness.model.logo.BusinessLogo; import org.mxchange.jcontactsbusiness.model.logo.Logo; import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; @@ -47,7 +48,6 @@ import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber; import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumber; import org.mxchange.jusercore.model.user.LoginUser; import org.mxchange.jusercore.model.user.User; -import org.mxchange.jcontactsbusiness.model.headquarters.Headquarter; /** * A POJO for business basic data @@ -59,7 +59,6 @@ import org.mxchange.jcontactsbusiness.model.headquarters.Headquarter; @NamedQueries ( { @NamedQuery (name = "AllBusinessData", query = "SELECT b FROM company_basic_data AS b ORDER BY b.basicDataId"), - @NamedQuery (name = "SearchBusinessDataById", query = "SELECT b FROM company_basic_data AS b WHERE b.basicDataId = :basicDataId") } ) @SuppressWarnings ("PersistenceUnitPresent") diff --git a/src/org/mxchange/jcontactsbusiness/model/branchoffice/BusinessBranchOffice.java b/src/org/mxchange/jcontactsbusiness/model/branchoffice/BusinessBranchOffice.java index 8c23a74..a24b326 100644 --- a/src/org/mxchange/jcontactsbusiness/model/branchoffice/BusinessBranchOffice.java +++ b/src/org/mxchange/jcontactsbusiness/model/branchoffice/BusinessBranchOffice.java @@ -62,7 +62,6 @@ import org.mxchange.jusercore.model.user.User; @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") diff --git a/src/org/mxchange/jcontactsbusiness/model/employee/BusinessEmployee.java b/src/org/mxchange/jcontactsbusiness/model/employee/BusinessEmployee.java index 2e5c606..d2407d7 100644 --- a/src/org/mxchange/jcontactsbusiness/model/employee/BusinessEmployee.java +++ b/src/org/mxchange/jcontactsbusiness/model/employee/BusinessEmployee.java @@ -35,20 +35,20 @@ import javax.persistence.TemporalType; import javax.persistence.Transient; import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jcontacts.model.contact.UserContact; +import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData; import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; import org.mxchange.jcontactsbusiness.model.branchoffice.BusinessBranchOffice; import org.mxchange.jcontactsbusiness.model.department.BusinessDepartment; import org.mxchange.jcontactsbusiness.model.department.Department; import org.mxchange.jcontactsbusiness.model.headquarters.BusinessHeadquarters; +import org.mxchange.jcontactsbusiness.model.headquarters.Headquarter; import org.mxchange.jcontactsbusiness.model.jobposition.EmployeePosition; import org.mxchange.jcontactsbusiness.model.jobposition.JobPosition; import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber; import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumber; import org.mxchange.jusercore.model.user.LoginUser; import org.mxchange.jusercore.model.user.User; -import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; -import org.mxchange.jcontactsbusiness.model.headquarters.Headquarter; /** * A POJO for company employees (including CEO) @@ -60,7 +60,6 @@ import org.mxchange.jcontactsbusiness.model.headquarters.Headquarter; @NamedQueries ( { @NamedQuery (name = "AllEmployees", query = "SELECT e FROM company_employees AS e ORDER BY e.employeeId ASC"), - @NamedQuery (name = "SearchEmployeeById", query = "SELECT e FROM company_employees AS e WHERE e.employeeId = :employeeId") } ) @SuppressWarnings ("PersistenceUnitPresent") diff --git a/src/org/mxchange/jcontactsbusiness/model/headquarters/BusinessHeadquarters.java b/src/org/mxchange/jcontactsbusiness/model/headquarters/BusinessHeadquarters.java index 892bf8d..fc8dc39 100644 --- a/src/org/mxchange/jcontactsbusiness/model/headquarters/BusinessHeadquarters.java +++ b/src/org/mxchange/jcontactsbusiness/model/headquarters/BusinessHeadquarters.java @@ -30,6 +30,8 @@ import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; import javax.persistence.OneToOne; import javax.persistence.Table; import javax.persistence.Temporal; @@ -55,6 +57,11 @@ import org.mxchange.jusercore.model.user.User; */ @Entity (name = "company_headquarters") @Table (name = "company_headquarters") +@NamedQueries ( + { + @NamedQuery (name = "AllHeadquarters", query = "SELECT hq FROM company_headquarters AS hq ORDER BY hq.headquartersId ASC") + } +) @SuppressWarnings ("PersistenceUnitPresent") public class BusinessHeadquarters implements Headquarter { @@ -96,7 +103,7 @@ public class BusinessHeadquarters implements Headquarter { /** * Email address of headquarters */ - @Column( name = "headquarters_email_address") + @Column (name = "headquarters_email_address") private String headquartersEmailAddress; /** @@ -181,37 +188,37 @@ public class BusinessHeadquarters implements Headquarter { // Validate parameters if (null == headquartersCity) { // Throw NPE - throw new NullPointerException("headquartersCity is null"); + throw new NullPointerException("headquartersCity is null"); //NOI18N } else if (headquartersCity.isEmpty()) { // Throw IAE - throw new IllegalArgumentException("headquartersCity is empty"); + throw new IllegalArgumentException("headquartersCity is empty"); //NOI18N } else if (null == headquartersCountry) { // Throw NPE - throw new NullPointerException("headquartersCountry is null"); + throw new NullPointerException("headquartersCountry is null"); //NOI18N } else if (headquartersCountry.getCountryId() == null) { // Throw NPE again - throw new NullPointerException("headquartersCountry.countryId is null"); + throw new NullPointerException("headquartersCountry.countryId is null"); //NOI18N } else if (headquartersCountry.getCountryId() < 1) { // Throw IAE - throw new IllegalArgumentException(MessageFormat.format("headquartersCountry.countryId={0} is not valid.", headquartersCountry.getCountryId())); + throw new IllegalArgumentException(MessageFormat.format("headquartersCountry.countryId={0} is not valid.", headquartersCountry.getCountryId())); //NOI18N } else if (null == headquartersHouseNumber) { // Throw NPE - throw new NullPointerException("headquartersHouseNumber is null"); - } else if (headquartersHouseNumber <1) { + throw new NullPointerException("headquartersHouseNumber is null"); //NOI18N + } else if (headquartersHouseNumber < 1) { // Throw IAE - throw new IllegalArgumentException(MessageFormat.format("headquartersHouseNumber={0} is invalid.", headquartersHouseNumber)); + throw new IllegalArgumentException(MessageFormat.format("headquartersHouseNumber={0} is invalid.", headquartersHouseNumber)); //NOI18N } else if (null == headquartersStreet) { // Throw NPE - throw new NullPointerException("headquartersStreet is null"); + throw new NullPointerException("headquartersStreet is null"); //NOI18N } else if (headquartersStreet.isEmpty()) { // Throw IAE - throw new IllegalArgumentException("headquartersStreet is empty"); + throw new IllegalArgumentException("headquartersStreet is empty"); //NOI18N } else if (null == headquartersZipCode) { // Throw NPE - throw new NullPointerException("headquartersZipCode is null"); - } else if (headquartersZipCode <1) { + throw new NullPointerException("headquartersZipCode is null"); //NOI18N + } else if (headquartersZipCode < 1) { // Throw IAE - throw new IllegalArgumentException(MessageFormat.format("headquartersZipCode={0} is invalid.", headquartersZipCode)); + throw new IllegalArgumentException(MessageFormat.format("headquartersZipCode={0} is invalid.", headquartersZipCode)); //NOI18N } // Set all fields diff --git a/src/org/mxchange/jcontactsbusiness/model/opening_time/BusinessOpeningTime.java b/src/org/mxchange/jcontactsbusiness/model/opening_time/BusinessOpeningTime.java index c794ea1..f164a51 100644 --- a/src/org/mxchange/jcontactsbusiness/model/opening_time/BusinessOpeningTime.java +++ b/src/org/mxchange/jcontactsbusiness/model/opening_time/BusinessOpeningTime.java @@ -44,7 +44,6 @@ import org.mxchange.jcontactsbusiness.model.opening_time.dayofweek.DayOfTheWeek; @NamedQueries ( { @NamedQuery (name = "AllOpeningTimes", query = "SELECT ot FROM company_opening_times AS ot ORDER BY ot.openingId ASC"), - @NamedQuery (name = "SearchOpeningTimesById", query = "SELECT ot FROM company_opening_times AS ot WHERE ot.openingId = :openingId") } ) @SuppressWarnings ("PersistenceUnitPresent") -- 2.39.5