Has anyone had an issue with a query finding the right number of hits in
a table, but all of the results returned are null? I've got a user
table with 304 entries. If I use the following code, I get the right
number of results returned:
Query query = em.createQuery("SELECT u FROM User u");
List<User> results = query.getResultList();
System.out.println("Results size = " + results.size());
However, if I try to call the toString() method on each User object, I
get a null for every one of them. Trying to access the username on a
User object throws a null pointer.
To further complicate things, I created an entry with the username
"testUser" in the database. If I change my query to "SELECT u FROM User
u where u.username = 'testUser'" I get one result returned, just as
expected. However, trying to assign that single result to a User object
with (User)query.getSingleResult() results in a null as well.
Help!
Derry Cannon