Why do username and password return null?
<p>So I have this username and password validation code using Java persistence.</p>

<pre><code>public Subscriber validateLogin(String username, String password)
{
   EntityManager em = getEntityManager();

    Query q = em.createQuery("SELECT s FROM Subscriber s WHERE s.username = :username OR s.password = :password ");

    q.setParameter("username", username);
    q.setParameter("password", password);

    try
    {
        return (Subscriber) q.getSingleResult();
    }
    catch (Exception e)
    {
        return null;
    }
}
</code></pre>

<p>So I check if the subscriber return anything or <code>null</code>. Here is my code:</p>

<pre><code>private void jButton3ActionPerformed(java.awt.event.ActionEvent evt)
{
    // TODO add your handling code here:
    SubscriberJpaController sjc = new SubscriberJpaController();
    Subscriber sub = sjc.validateLogin(jTextField1.getText(), jPasswordField1.getText());

    System.out.println(sub);
}
</code></pre>

<p>and it returns <code>null</code>. Anything wrong with my code or logic?</p>
