Package dao.jpa

Source Code of dao.jpa.OrderStateJpaDao

package dao.jpa;

import dao.DataAccessException;
import dao.OrderStateDao;
import models.entities.OrderState;
import play.Logger;
import play.db.jpa.JPA;

import javax.persistence.TypedQuery;

/**
* Created by kiryl on 17.08.2014.
*/
public class OrderStateJpaDao extends BaseJpaDao<OrderState, Integer> implements OrderStateDao {
    public OrderState findByName(String stateName) throws DataAccessException {
        if (stateName == null) {
            return null;
        }
        try {
            TypedQuery<OrderState> query = JPA.em()
                    .createQuery("SELECT r FROM OrderState r WHERE r.name = :stateName", OrderState.class);
            query.setParameter("stateName", stateName);
            return query.getSingleResult();
        } catch (Throwable throwable) {
            Logger.error("Failed to get role by name: " + stateName);
            throw new DataAccessException("Failed to get role by name: " + stateName, throwable);
        }
    }
}
TOP

Related Classes of dao.jpa.OrderStateJpaDao

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.