Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Blazebit#720] Add workaround for EclipseLink issue that returns obje…
Browse files Browse the repository at this point in the history
…ct of wrong type for count expression
beikov committed Jan 21, 2019
1 parent a1243fb commit b14f3df
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -137,7 +137,7 @@ private String getParameterName(Parameter<?> parameter) {

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

@Override
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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) {

0 comments on commit b14f3df

Please sign in to comment.