import java.text.MessageFormat;
import java.util.List;
import javax.ejb.Stateless;
-import javax.persistence.NoResultException;
import javax.persistence.Query;
-import org.mxchange.jcontactsbusiness.exceptions.opening_time.OpeningTimeNotFoundException;
import org.mxchange.jfinancials.database.BaseFinancialsDatabaseBean;
/**
return list;
}
- @Override
- public OpeningTime findOpeningTimesById (final Long departmentId) throws OpeningTimeNotFoundException {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findOpeningTimesById: CALLED!", this.getClass().getSimpleName())); //NOI18N
-
- // Validate parameter
- if (null == departmentId) {
- // Throw NPE
- throw new NullPointerException("departmentId is null"); //NOI18N
- } else if (departmentId < 1) {
- // Throw NPE
- throw new NullPointerException(MessageFormat.format("departmentId={0}is invalid", departmentId)); //NOI18N
- }
-
- // Get query
- final Query query = this.getEntityManager().createNamedQuery("SearchOpeningTimesById", BusinessOpeningTime.class); //NOI18N
-
- // Set parameter
- query.setParameter("departmentId", departmentId); //NOI18N
-
- // Get single instance
- final OpeningTime department;
-
- // Try to find a result
- try {
- // Find a single result
- department = (OpeningTime) query.getSingleResult();
-
- // Log trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findOpeningTimesById: Found department={1}", this.getClass().getSimpleName(), department)); //NOI18N
- } catch (final NoResultException ex) {
- // No result found
- throw new OpeningTimeNotFoundException(departmentId, ex);
- }
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findOpeningTimesById: department={1} - EXIT!", this.getClass().getSimpleName(), department)); //NOI18N
-
- // Return it
- return department;
- }
-
}