Package com.gtdev.web.dao.impl

Source Code of com.gtdev.web.dao.impl.UserDAOImpl

package com.gtdev.web.dao.impl;

import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;

import org.springframework.transaction.annotation.Transactional;

import com.gtdev.web.dao.UserDAO;
import com.gtdev.web.stereotype.Dao;
import com.gtdev.web.store.User;

/** @author Gregory Tardivel */
@Dao("userDAO")
@Transactional
public final class UserDAOImpl implements UserDAO {

    @PersistenceContext
    private EntityManager manager;

    @Override
    public User find(final String pEmail) {
        User retour = null;
        try {
            final TypedQuery<User> query = this.manager.createNamedQuery(
                    "User.find", User.class);
            query.setParameter("param", pEmail);
            retour = query.getSingleResult();
        } catch (final NoResultException exc) {
            retour = null;
        }
        return retour;
    }

    @Override
    public void save(final User pUser) {
        this.manager.persist(pUser);
    }

}
TOP

Related Classes of com.gtdev.web.dao.impl.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.