- 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
--- /dev/null
+/*
+ * 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
+ }
+
+}
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;
*/
@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 {
/**
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;
*/
@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 {
/**
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;
*/
@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 {
/**