I have had this problem for a month now. I am trying to execute a JPA query 
from a session bean, and everytime it returns only null. Other functionalities 
of the entity bean like persist() works, and stores database. What am i doing 
wrong here. My code is attached below:


import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

@Stateless

public class LoginBean implements LoginBeanRemote, LoginBeanLocal {

        public LoginBean() {
    
    }
        
        @PersistenceContext(unitName="CustomerUnit")
        EntityManager manager;
        
    public String validateLogin(String userName, String password)
    {
        try
        {
                Query q1 = manager.createQuery("SELECT c FROM Customer c WHERE 
c.userName = :username AND c.password = :password ");
                q1.setParameter("username", userName);
                q1.setParameter("password", password);
                System.out.println(q1.getSingleResult());
                
        }
        catch(Exception e)
        {
                e.printStackTrace();
        }
        
        return "loginUser";
    }
}


View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4216028#4216028

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4216028
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to