]> git.mxchange.org Git - jphone-core.git/commitdiff
Continued a bit:
authorRoland Haeder <roland@mxchange.org>
Sun, 17 Apr 2016 10:35:24 +0000 (12:35 +0200)
committerRoland Haeder <roland@mxchange.org>
Sun, 17 Apr 2016 10:35:24 +0000 (12:35 +0200)
- added named queries for finding cell phone, fax and land-line entries by id number
- added Exception thrown when the corresponding entity was not found

src/org/mxchange/jphone/exceptions/PhoneEntityNotFoundException.java [new file with mode: 0644]
src/org/mxchange/jphone/phonenumbers/cellphone/CellphoneNumber.java
src/org/mxchange/jphone/phonenumbers/fax/FaxNumber.java
src/org/mxchange/jphone/phonenumbers/landline/LandLineNumber.java

diff --git a/src/org/mxchange/jphone/exceptions/PhoneEntityNotFoundException.java b/src/org/mxchange/jphone/exceptions/PhoneEntityNotFoundException.java
new file mode 100644 (file)
index 0000000..5623c56
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * 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.jphone.exceptions;
+
+import java.text.MessageFormat;
+
+/**
+ * An exception thrown when a phone entity is not found.
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public class PhoneEntityNotFoundException extends Exception {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 18_964_581_681_985_597L;
+
+       /**
+        * Counstructor with id number and causing exception
+        * <p>
+        * @param cellphoneId Id number that has no corresponding entity
+        * @param cause Causing exception
+        */
+       public PhoneEntityNotFoundException (final Long cellphoneId, final Throwable cause) {
+               // Construct message and call super constructor
+               super(MessageFormat.format("Cell phone entity with id {0} not found.", cellphoneId), cause); //NOI18N
+       }
+
+}
index ce74ed55440a57df2cb034173057df8842b2dc4e..75856e53d91abc5dc1ce1af46864d7f25600f4af 100644 (file)
@@ -26,6 +26,8 @@ import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.JoinColumn;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
 import javax.persistence.OneToOne;
 import javax.persistence.Table;
 import javax.persistence.Temporal;
@@ -41,6 +43,9 @@ import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
  */
 @Entity (name = "cellphone_numbers")
 @Table (name = "cellphone_numbers")
+@NamedQueries (
+               @NamedQuery (name = "SearchCellphoneId", query = "SELECT c FROM cellphone_numbers AS c WHERE c.phoneId = :cellphoneId")
+)
 public class CellphoneNumber implements DialableCellphoneNumber {
 
        /**
index 18db59db3d5d65fd265792093ee9e0280dcdfb5b..45022e1eaed1ab7e92f6838b46e5d6d221577aed 100644 (file)
@@ -26,6 +26,8 @@ import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.JoinColumn;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
 import javax.persistence.OneToOne;
 import javax.persistence.Table;
 import javax.persistence.Temporal;
@@ -40,6 +42,9 @@ import org.mxchange.jcountry.data.CountryData;
  */
 @Entity (name = "fax_numbers")
 @Table (name = "fax_numbers")
+@NamedQueries (
+               @NamedQuery (name = "SearchFaxId", query = "SELECT f FROM fax_numbers AS f WHERE f.phoneId = :faxId")
+)
 public class FaxNumber implements DialableFaxNumber {
 
        /**
index 52d89327cce37df3999ae3f23759e2b632a5e070..17ab3f0aafc4019bb45efb5891ad95ddf010b642 100644 (file)
@@ -26,6 +26,8 @@ import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.JoinColumn;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
 import javax.persistence.OneToOne;
 import javax.persistence.Table;
 import javax.persistence.Temporal;
@@ -40,6 +42,9 @@ import org.mxchange.jcountry.data.CountryData;
  */
 @Entity (name = "phone_numbers")
 @Table (name = "phone_numbers")
+@NamedQueries (
+               @NamedQuery (name = "SearchLandLineId", query = "SELECT p FROM phone_numbers AS p WHERE p.phoneId = :phoneId")
+)
 public class LandLineNumber implements DialableLandLineNumber {
 
        /**