SGG
SGG

Reputation: 165

Hibernate | Null elements in arraylist while getting all entries

While fetching all the entries from database it returns an ArrayList with error all elements cannot be null.

But when I fetch query with select one or one + elements, it returns the proper arraylist.

I tried but didn't find any useful working answer.

Thanks,

enter image description here

String String = "from abc rfi " +
                        "where rfi.a=:carrier " +
                        "and rfi.b=:fileStatus " +
                        "and rfi.c=:fileType ";

Query query = session.createQuery(queryString);
query.setParameter("fileStatus", fileStatus.value());
query.setParameter("carrier", carrier.value());
query.setParameter("fileType", fileType);

Upvotes: 1

Views: 411

Answers (2)

user8826113
user8826113

Reputation: 129

Since you said you filled all the data so just another check you can do. In your query, you add the values in where clause -

query.setParameter("fileStatus", fileStatus.value());

Is fileStatus is enum? If yes, are you sure you get the expected value from fileStatus.value() or data in DB exist with fileStatus.name()

Upvotes: 0

codesequel
codesequel

Reputation: 57

Hibernate may return all elements as null even if a single field of the primary key in the result is null.

Upvotes: 1

Related Questions