Package cz.muni.fi.pa165.ddtroops.daoclasses

Source Code of cz.muni.fi.pa165.ddtroops.daoclasses.UserDAOImpl

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package cz.muni.fi.pa165.ddtroops.daoclasses;

import cz.muni.fi.pa165.ddtroops.daointerfaces.UserDAO;
import cz.muni.fi.pa165.ddtroops.entities.User;
import java.util.List;
import org.springframework.stereotype.Repository;

/**
*
* @author newohybat
*/
@Repository(value = "userDAO")
public class UserDAOImpl extends BaseDAOImpl<User> implements UserDAO  {

    @Override
    protected boolean isValid(User object) {
        return  object.getName()!=null &&
                object.getPassword()!=null &&
                object.getAuthority()!=null;
    }

    @Override
    protected boolean isIn(User object) {
        return getById(object.getId())!=null;
    }

    public User getByName(String name){
        if (name == null || name.equals("")) {
            throw new IllegalArgumentException("Parameter name is null or empty string");
        }
        User hero = (User) super.getEntityManager().createQuery("SELECT u FROM User u WHERE u.name = :name").setParameter("name", name).getSingleResult();

        return hero;
    }

}
TOP

Related Classes of cz.muni.fi.pa165.ddtroops.daoclasses.UserDAOImpl

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.