]> git.mxchange.org Git - addressbook-ejb.git/blobdiff - src/java/org/mxchange/jcountry/data/AddressbookCountrySingletonBean.java
Continued with logging: (please cherry-pick)
[addressbook-ejb.git] / src / java / org / mxchange / jcountry / data / AddressbookCountrySingletonBean.java
index fbcdb44c42b7895b7bbd6550dd439f0faef3dae2..d3d196e9e87491f197e1d6edb4f02a756794d2a9 100644 (file)
@@ -27,12 +27,12 @@ import org.mxchange.jcoreee.database.BaseDatabaseBean;
 import org.mxchange.jcountry.exceptions.CountryAlreadyAddedException;
 
 /**
- * A singleton bean for country informations
+ * A singleton EJB for country informations
  * <p>
  * @author Roland Haeder<roland@mxchange.org>
  */
 @Startup
-@Singleton (name = "country", mappedName = "ejb/addressbook-singleton-country", description = "A singleton session bean for country informations")
+@Singleton (name = "country", description = "A singleton session bean for country informations")
 public class AddressbookCountrySingletonBean extends BaseDatabaseBean implements CountrySingletonBeanRemote {
 
        /**
@@ -41,7 +41,10 @@ public class AddressbookCountrySingletonBean extends BaseDatabaseBean implements
        private static final long serialVersionUID = 15_846_983_298_691_207L;
 
        @Override
-       public void addCountry (final Country country) throws CountryAlreadyAddedException {
+       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
@@ -68,16 +71,31 @@ public class AddressbookCountrySingletonBean extends BaseDatabaseBean 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;
        }
 
        @Override
        @SuppressWarnings ("unchecked")
        public List<Country> 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<Country> 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;
        }
 
        /**