From 0766135ca3aa8135294ff0678f5277c7d9b50dca Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 26 Apr 2016 09:40:54 +0200 Subject: [PATCH] type-hints to the JPA can also be interfaces, good! :-) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- nbproject/build-impl.xml | 8 ++++---- .../contact/PizzaContactSessionBean.java | 4 ++-- .../data/PizzaCountrySingletonBean.java | 3 ++- .../phone/PizzaPhoneSessionBean.java | 3 +-- .../model/user/PizzaUserSessionBean.java | 14 +++++++------- .../customer/PizzaAdminCustomerSessionBean.java | 17 +++++++++++++++-- .../customer/PizzaCustomerSessionBean.java | 2 +- 7 files changed, 32 insertions(+), 19 deletions(-) diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml index 6ab33ad..eb49030 100644 --- a/nbproject/build-impl.xml +++ b/nbproject/build-impl.xml @@ -25,8 +25,8 @@ is divided into following sections: - @@ -749,9 +749,9 @@ or ant -Dj2ee.platform.classpath=<server_classpath> (where no properties f The libs.CopyLibs.classpath property is not set up. -This property must point to +This property must point to org-netbeans-modules-java-j2seproject-copylibstask.jar file which is part -of NetBeans IDE installation and is usually located at +of NetBeans IDE installation and is usually located at <netbeans_installation>/java<version>/ant/extra folder. Either open the project in the IDE and make sure CopyLibs library exists or setup the property manually. For example like this: diff --git a/src/java/org/mxchange/jcontacts/contact/PizzaContactSessionBean.java b/src/java/org/mxchange/jcontacts/contact/PizzaContactSessionBean.java index ee42d89..5ff7fc8 100644 --- a/src/java/org/mxchange/jcontacts/contact/PizzaContactSessionBean.java +++ b/src/java/org/mxchange/jcontacts/contact/PizzaContactSessionBean.java @@ -22,7 +22,7 @@ import javax.ejb.Stateless; import javax.persistence.NoResultException; import javax.persistence.Query; import org.mxchange.jcontacts.exceptions.ContactNotFoundException; -import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean; +import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;; /** * A contact EJB @@ -58,7 +58,7 @@ public class PizzaContactSessionBean extends BasePizzaDatabaseBean implements Co } // Get query instance - Query query = this.getEntityManager().createNamedQuery("SearchContactById", UserContact.class); //NOI18N + Query query = this.getEntityManager().createNamedQuery("SearchContactById", Contact.class); //NOI18N // Set parameter query.setParameter("contactId", contactId); //NOI18N diff --git a/src/java/org/mxchange/jcountry/data/PizzaCountrySingletonBean.java b/src/java/org/mxchange/jcountry/data/PizzaCountrySingletonBean.java index 87d67df..feb8340 100644 --- a/src/java/org/mxchange/jcountry/data/PizzaCountrySingletonBean.java +++ b/src/java/org/mxchange/jcountry/data/PizzaCountrySingletonBean.java @@ -16,6 +16,7 @@ */ package org.mxchange.jcountry.data; +import de.chotime.jratecalc.database.BasePizzaDatabaseBean; import java.text.MessageFormat; import java.util.GregorianCalendar; import java.util.List; @@ -110,7 +111,7 @@ public class PizzaCountrySingletonBean extends BasePizzaDatabaseBean implements boolean isAdded = false; // Get query instance - Query query = this.getEntityManager().createNamedQuery("SearchCountryByCodeI18nKey", CountryData.class); //NOI18N + Query query = this.getEntityManager().createNamedQuery("SearchCountryByCodeI18nKey", Country.class); //NOI18N // Assign all parameters query.setParameter("code", country.getCountryCode()); //NOI18N diff --git a/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaPhoneSessionBean.java b/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaPhoneSessionBean.java index 3f4cb50..a7c0e1c 100644 --- a/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaPhoneSessionBean.java +++ b/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaPhoneSessionBean.java @@ -21,7 +21,6 @@ import javax.ejb.Stateless; import javax.persistence.NoResultException; import javax.persistence.Query; import org.mxchange.jphone.exceptions.PhoneEntityNotFoundException; -import org.mxchange.jphone.phonenumbers.cellphone.CellphoneNumber; import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber; import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean; @@ -59,7 +58,7 @@ public class PizzaPhoneSessionBean extends BasePizzaDatabaseBean implements Phon } // Now find it - Query query = this.getEntityManager().createNamedQuery("SearchCellphoneId", CellphoneNumber.class); //NOI18N + Query query = this.getEntityManager().createNamedQuery("SearchCellphoneId", DialableCellphoneNumber.class); //NOI18N // Set parameter query.setParameter("cellphoneId", cellphoneId); //NOI18N diff --git a/src/java/org/mxchange/jusercore/model/user/PizzaUserSessionBean.java b/src/java/org/mxchange/jusercore/model/user/PizzaUserSessionBean.java index f3130b4..7cfa90f 100644 --- a/src/java/org/mxchange/jusercore/model/user/PizzaUserSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/user/PizzaUserSessionBean.java @@ -203,7 +203,7 @@ public class PizzaUserSessionBean extends BasePizzaDatabaseBean implements UserS } // Try to locate it - Query query = this.getEntityManager().createNamedQuery("SearchUserName", LoginUser.class); //NOI18N + Query query = this.getEntityManager().createNamedQuery("SearchUserName", User.class); //NOI18N // Set parameter query.setParameter("param", user.getUserName()); //NOI18N @@ -242,7 +242,7 @@ public class PizzaUserSessionBean extends BasePizzaDatabaseBean implements UserS } // Create query instance - Query query = this.getEntityManager().createNamedQuery("SearchUserId", LoginUser.class); //NOI18N + Query query = this.getEntityManager().createNamedQuery("SearchUserId", User.class); //NOI18N // Set user id query.setParameter("id", userId); //NOI18N @@ -301,7 +301,7 @@ public class PizzaUserSessionBean extends BasePizzaDatabaseBean implements UserS } // Generate query - Query query = this.getEntityManager().createNamedQuery("SearchUserId", LoginUser.class); //NOI18N + Query query = this.getEntityManager().createNamedQuery("SearchUserId", User.class); //NOI18N // Set parameter query.setParameter("id", user.getUserId()); //NOI18N @@ -348,7 +348,7 @@ public class PizzaUserSessionBean extends BasePizzaDatabaseBean implements UserS } // Generate query - Query query = this.getEntityManager().createNamedQuery("SearchUserId", LoginUser.class); //NOI18N + Query query = this.getEntityManager().createNamedQuery("SearchUserId", User.class); //NOI18N // Set parameter query.setParameter("id", userId); //NOI18N @@ -395,7 +395,7 @@ public class PizzaUserSessionBean extends BasePizzaDatabaseBean implements UserS } // Generate query - Query query = this.getEntityManager().createNamedQuery("SearchUserName", LoginUser.class); //NOI18N + Query query = this.getEntityManager().createNamedQuery("SearchUserName", User.class); //NOI18N // Set parameter query.setParameter("param", userName); //NOI18N @@ -433,7 +433,7 @@ public class PizzaUserSessionBean extends BasePizzaDatabaseBean implements UserS } // Generate query - Query query = this.getEntityManager().createNamedQuery("SearchEmailAddress", LoginUser.class); //NOI18N + Query query = this.getEntityManager().createNamedQuery("SearchEmailAddress", User.class); //NOI18N // Set parameter query.setParameter("param", user.getUserContact().getContactEmailAddress()); //NOI18N @@ -474,7 +474,7 @@ public class PizzaUserSessionBean extends BasePizzaDatabaseBean implements UserS } // Generate query - Query query = this.getEntityManager().createNamedQuery("SearchUserName", LoginUser.class); //NOI18N + Query query = this.getEntityManager().createNamedQuery("SearchUserName", User.class); //NOI18N // Set parameter query.setParameter("param", user.getUserName()); //NOI18N diff --git a/src/java/org/mxchange/pizzaapplication/model/customer/PizzaAdminCustomerSessionBean.java b/src/java/org/mxchange/pizzaapplication/model/customer/PizzaAdminCustomerSessionBean.java index b338715..6a9b845 100644 --- a/src/java/org/mxchange/pizzaapplication/model/customer/PizzaAdminCustomerSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/model/customer/PizzaAdminCustomerSessionBean.java @@ -19,6 +19,7 @@ package org.mxchange.pizzaapplication.model.customer; import java.text.MessageFormat; import java.util.List; import javax.ejb.Stateless; +import javax.persistence.NoResultException; import javax.persistence.Query; import org.mxchange.jcustomercore.model.customer.Customer; import org.mxchange.jcustomercore.utils.CustomerUtils; @@ -59,7 +60,7 @@ public class PizzaAdminCustomerSessionBean extends BasePizzaDatabaseBean impleme @Override public String createCustomerNumber () { // Init named query - Query query = this.getEntityManager().createNamedQuery("SearchCustomerByNumber", RateCalcCustomer.class); + Query query = this.getEntityManager().createNamedQuery("SearchCustomerByNumber", Customer.class); // Default is not found String customerNumber = null; @@ -67,7 +68,19 @@ public class PizzaAdminCustomerSessionBean extends BasePizzaDatabaseBean impleme // Search until a free number was found while (null == customerNumber) { // Create new number - String cn = CustomerUtils.generateCustomerNumber(RateCalcAdminCustomerSessionBeanRemote.CUSTOMER_NUMBER_LENGTH); + String cn = CustomerUtils.generateCustomerNumber(PizzaAdminCustomerSessionBeanRemote.CUSTOMER_NUMBER_LENGTH, PizzaAdminCustomerSessionBeanRemote.CUSTOMER_NUMBER_BLOCK_SIZE, PizzaAdminCustomerSessionBeanRemote.CUSTOMER_NUMBER_SEPARATOR); + + // Set the generated number as param + query.setParameter("customerNumber", cn); + + // Try to find it + try { + // Get a single result + Customer customer = (Customer) query.getSingleResult(); + } catch (final NoResultException ex) { + // Not found, okay + customerNumber = cn; + } } } diff --git a/src/java/org/mxchange/pizzaapplication/model/customer/PizzaCustomerSessionBean.java b/src/java/org/mxchange/pizzaapplication/model/customer/PizzaCustomerSessionBean.java index b8732b1..cbf716e 100644 --- a/src/java/org/mxchange/pizzaapplication/model/customer/PizzaCustomerSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/model/customer/PizzaCustomerSessionBean.java @@ -45,7 +45,7 @@ public class PizzaCustomerSessionBean extends BasePizzaDatabaseBean implements P @Override public Customer registerCustomer (final Customer customer) throws CustomerAlreadyRegisteredException { - throw new UnsupportedOperationException("Registration by guests is not supported with RateCalc application."); //NOI18N + throw new UnsupportedOperationException("Registration by guests is not supported with Pizza application."); //NOI18N } } -- 2.39.5