X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2Fjava%2Forg%2Fmxchange%2Fjcountry%2Fdata%2FPizzaCountrySingletonBean.java;h=380cf1511bf84e24c1bd9e1d270521b27434772b;hb=ced2afa1d700ce61b6ef4f3adacdb0a87c16e477;hp=feb834039ac8926851e978e6ffc764cb866da89b;hpb=0766135ca3aa8135294ff0678f5277c7d9b50dca;p=pizzaservice-ejb.git
diff --git a/src/java/org/mxchange/jcountry/data/PizzaCountrySingletonBean.java b/src/java/org/mxchange/jcountry/data/PizzaCountrySingletonBean.java
index feb8340..380cf15 100644
--- a/src/java/org/mxchange/jcountry/data/PizzaCountrySingletonBean.java
+++ b/src/java/org/mxchange/jcountry/data/PizzaCountrySingletonBean.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Roland Haeder
+ * Copyright (C) 2016 Roland Häder
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
@@ -16,7 +16,6 @@
*/
package org.mxchange.jcountry.data;
-import de.chotime.jratecalc.database.BasePizzaDatabaseBean;
import java.text.MessageFormat;
import java.util.GregorianCalendar;
import java.util.List;
@@ -30,10 +29,10 @@ import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
/**
* A singleton EJB for country informations
*
- * @author Roland Haeder
+ * @author Roland Häder
*/
@Startup
-@Singleton (name = "country", mappedName = "ejb/pizzaservice-singleton-country", description = "A singleton session bean for country informations")
+@Singleton (name = "country", description = "A singleton session bean for country informations")
public class PizzaCountrySingletonBean extends BasePizzaDatabaseBean implements CountrySingletonBeanRemote {
/**
@@ -43,6 +42,9 @@ public class PizzaCountrySingletonBean extends BasePizzaDatabaseBean implements
@Override
public Country addCountry (final Country country) throws CountryAlreadyAddedException {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addCountry: country={1} - CALLED!", this.getClass().getSimpleName(), country)); //NOI18N
+
// Is it already there?
if (null == country) {
// Throw NPE
@@ -50,7 +52,7 @@ public class PizzaCountrySingletonBean extends BasePizzaDatabaseBean implements
} else if (country.getCountryCode().isEmpty()) {
// Code is not set
throw new IllegalArgumentException("country.countryCode is empty"); //NOI18N
- } else if (country.getCountryI18nkey().isEmpty()) {
+ } else if (country.getCountryI18nKey().isEmpty()) {
// I18n key is not set
throw new IllegalArgumentException("country.countryI18nKey is empty"); //NOI18N
} else if (country.getCountryId() != null) {
@@ -70,6 +72,9 @@ public class PizzaCountrySingletonBean extends BasePizzaDatabaseBean implements
// Flush it to get id number back, maybe it is directly needed?
this.getEntityManager().flush();
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addCountry: country={1} - EXIT!", this.getClass().getSimpleName(), country)); //NOI18N
+
// Return updated instance
return country;
}
@@ -77,11 +82,20 @@ public class PizzaCountrySingletonBean extends BasePizzaDatabaseBean implements
@Override
@SuppressWarnings ("unchecked")
public List allCountries () {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allCountries: CALLED!", this.getClass().getSimpleName())); //NOI18N
+
// Init query
- Query query = this.getEntityManager().createNamedQuery("AllCountries", List.class); //NOI18N
+ Query query = this.getEntityManager().createNamedQuery("AllCountries", CountryData.class); //NOI18N
+
+ // Get list
+ List countries = query.getResultList();
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allCountries: countries.size()={1} - EXIT!", this.getClass().getSimpleName(), countries.size())); //NOI18N
// Return it
- return query.getResultList();
+ return countries;
}
/**
@@ -99,7 +113,7 @@ public class PizzaCountrySingletonBean extends BasePizzaDatabaseBean implements
} else if (country.getCountryCode().isEmpty()) {
// Code is not set
throw new IllegalArgumentException("country.countryCode is empty"); //NOI18N
- } else if (country.getCountryI18nkey().isEmpty()) {
+ } else if (country.getCountryI18nKey().isEmpty()) {
// I18n key is not set
throw new IllegalArgumentException("country.countryI18nKey is empty"); //NOI18N
} else if (country.getCountryId() != null) {
@@ -111,11 +125,11 @@ public class PizzaCountrySingletonBean extends BasePizzaDatabaseBean implements
boolean isAdded = false;
// Get query instance
- Query query = this.getEntityManager().createNamedQuery("SearchCountryByCodeI18nKey", Country.class); //NOI18N
+ Query query = this.getEntityManager().createNamedQuery("SearchCountryByCodeI18nKey", CountryData.class); //NOI18N
// Assign all parameters
query.setParameter("code", country.getCountryCode()); //NOI18N
- query.setParameter("key", country.getCountryI18nkey()); //NOI18N
+ query.setParameter("key", country.getCountryI18nKey()); //NOI18N
// Try to get a single result
try {