* @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 {
/**
@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
} 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) {
// 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;
}
/**
} 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) {
// 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 {