X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2Fjava%2Forg%2Fmxchange%2Fjcountry%2Fdata%2FJobsCountrySingletonBean.java;h=38275840b1f7859652ffdc48bd874c3a9f82f1c9;hb=fb386c02c2750e0d82d81cd8bae84b81ffb661ce;hp=0dfc8571e72a7b06c0dc3db08baa8d687d131d5b;hpb=8cf73c04ac6018bcb2b48a3190d298df6a84a234;p=jjobs-ejb.git
diff --git a/src/java/org/mxchange/jcountry/data/JobsCountrySingletonBean.java b/src/java/org/mxchange/jcountry/data/JobsCountrySingletonBean.java
index 0dfc857..3827584 100644
--- a/src/java/org/mxchange/jcountry/data/JobsCountrySingletonBean.java
+++ b/src/java/org/mxchange/jcountry/data/JobsCountrySingletonBean.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Roland Haeder
+ * Copyright (C) 2016, 2017 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
@@ -23,17 +23,17 @@ import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.persistence.NoResultException;
import javax.persistence.Query;
-import org.mxchange.jcoreee.database.BaseDatabaseBean;
import org.mxchange.jcountry.exceptions.CountryAlreadyAddedException;
+import org.mxchange.jjobs.database.BaseJobsDatabaseBean;
/**
- * A singleton bean for country informations
+ * A singleton EJB for country informations
*
- * @author Roland Haeder
+ * @author Roland Häder
*/
@Startup
-@Singleton (name = "country", mappedName = "ejb/jjobs-singleton-country", description = "A singleton session bean for country informations")
-public class JobsCountrySingletonBean extends BaseDatabaseBean implements CountrySingletonBeanRemote {
+@Singleton (name = "country", description = "A singleton session-scoped bean for country informations")
+public class JobsCountrySingletonBean extends BaseJobsDatabaseBean implements CountrySingletonBeanRemote {
/**
* Serial number
@@ -41,7 +41,10 @@ public class JobsCountrySingletonBean extends BaseDatabaseBean implements Countr
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
@@ -49,7 +52,7 @@ public class JobsCountrySingletonBean extends BaseDatabaseBean implements Countr
} 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) {
@@ -68,16 +71,31 @@ public class JobsCountrySingletonBean extends BaseDatabaseBean implements Countr
// 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 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;
}
/**
@@ -95,7 +113,7 @@ public class JobsCountrySingletonBean extends BaseDatabaseBean implements Countr
} 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,7 +129,7 @@ public class JobsCountrySingletonBean extends BaseDatabaseBean implements Countr
// 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 {