Skip to content

Commit

Permalink
[#720] Add workaround for EclipseLink issue that returns object of wr…
Browse files Browse the repository at this point in the history
…ong type for count expression
  • Loading branch information
beikov committed Feb 25, 2019
1 parent b35b643 commit a6c0136
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private String getParameterName(Parameter<?> parameter) {

@Override
public long getTotalCount() {
return (Long) countQuery.getSingleResult();
return ((Number) countQuery.getSingleResult()).longValue();
}

@Override
Expand All @@ -155,18 +155,18 @@ public PagedList<X> getResultList() {
long totalSize = -1L;
if (withCount) {
if (entityId == null) {
totalSize = (Long) countQuery.getSingleResult();
totalSize = ((Number) countQuery.getSingleResult()).longValue();
} else {
Object[] result = (Object[]) countQuery.getSingleResult();
totalSize = (Long) result[0];
totalSize = ((Number) result[0]).longValue();

if (result[1] == null) {
// If the reference entity id is not contained (i.e. has no position), we return this special value
queryFirstResult = -1;
firstRow = 0;
} else {
// The page position is numbered from 1 so we need to correct this here
int position = ((Long) result[1]).intValue() - 1;
int position = ((Number) result[1]).intValue() - 1;
queryFirstResult = firstRow = position == 0 ? 0 : position - (position % pageSize);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ public V findOne(ID id) {

public long count() {
TypedQuery<Long> countQuery = getCountQuery(null, getDomainClass());
return countQuery.getSingleResult();
return ((Number) countQuery.getSingleResult()).longValue();
}

public boolean existsById(ID id) {
Expand Down

0 comments on commit a6c0136

Please sign in to comment.