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);
}
}