title: JPA BigInteger and Long issue
body: <p>I have a piece of code like this:</p>
  
  <pre><code>CriteriaBuilder cb = em.getCriteriaBuilder();
  CriteriaQuery&lt;Offer&gt; query = cb.createQuery(Offer.class);
  Root&lt;Offer&gt; root = query.from(Offer.class);
  query = query.select(root).where(cb.equal(root.get(Offer_.companyID), company.getId()));
  return em.createQuery(query).getResultList()
  </code></pre>
  
  <p>Now, this looks nice and dandy, but it gives me problems. Both offer.companyID and company.id are long.</p>
  
  <p>Here's the what log shows me that hibernate is doing:</p>
  
  <pre><code> Hibernate: SELECT C.id FROM company C INNER JOIN company_operators cm
   ON cm.company_id = c.id WHERE cm.operators_id = '503'
  </code></pre>
  
  <p>And this is the error I get:</p>
  
  <pre><code>12:47:00,581 ERROR [org.jboss.ejb3.invocation] (http--0.0.0.0-9080-5) JBAS014134: EJB Invocation failed on component OfferRepository for method public java.util.List org.jboss.tools.example.richfaces.data.OfferRepository.getOffersbyMemberId(java.lang.Long) throws java.lang.Exception: javax.ejb.EJBException: java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long
  </code></pre>
  
  <p>What could be the problem here?</p>