question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Predicate throws IllegalArgumentException

See original GitHub issue

springboot version: 1.5.9 querydsl version: 4.1.4

service query code:

    public List<Timeline> searchAllByUserId(long userId, int pageIndex, int pageSize) {
        QTimeline qTimeline = QTimeline.timeline;
        Predicate predicate = qTimeline.userId.longValue().eq(userId);
        PageRequest page = new PageRequest(pageIndex, pageSize, new Sort(Sort.Direction.DESC, "createAt"));

        return timelineRepository.findAllByUserId(predicate, page);
    }

exception:

org.springframework.dao.InvalidDataAccessApiUsageException: Parameter value [timeline.userId = 2] did not match expected type [java.lang.Long (n/a)]; nested exception is java.lang.IllegalArgumentException: Parameter value [timeline.userId = 2] did not match expected type [java.lang.Long (n/a)]

Caused by: java.lang.IllegalArgumentException: Parameter value [timeline.userId = 2] did not match expected type [java.lang.Long (n/a)]
	at org.hibernate.jpa.spi.BaseQueryImpl.validateBinding(BaseQueryImpl.java:897)
	at org.hibernate.jpa.internal.QueryImpl.access$000(QueryImpl.java:61)
	at org.hibernate.jpa.internal.QueryImpl$ParameterRegistrationImpl.bindValue(QueryImpl.java:235)
	at org.hibernate.jpa.spi.BaseQueryImpl.setParameter(BaseQueryImpl.java:638)

anyone could give me some tips ?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Shredder121commented, May 22, 2018

findAllByUserId

Spring data will generate a select ... where user.id = ? query. So you just pass in the id, not a predicate.

1reaction
linyongfu2013commented, May 22, 2018

so disappointed no one give a damn to new issue… @meatballhat @rocketraman @johnktims @ponzao @msiedlarek

Read more comments on GitHub >

github_iconTop Results From Across the Web

Java Predicates In clause: illegal argument exception?
What is the issue? private Long getResultsCount(Predicate predicate) throws ATSException { CriteriaBuilder countBuilder = entityManager ...
Read more >
Predicate Illegal Argument Exception - Google Groups
Hi,. I am using SQLPredicate in my application. My keys are strings and values are VersionedPortable Objects. int mdns_hazelcast_map_init ...
Read more >
janusgraph-users@lists.lfaidata.foundation | Connective predicate ...
Connective predicate with id throws an IllegalArgumentException (Invalid condition) ... predicate with string ids, it fails with an IllegalArgumentException:.
Read more >
Predicate (Java Platform SE 8 ) - Oracle Help Center
Returns a composed predicate that represents a short-circuiting logical OR of this predicate and another. When evaluating the composed predicate, if this ...
Read more >
Source code - Apache Commons - The Apache Software Foundation!
Predicate; 031import org.apache.commons.collections4.bag. ... if collection or predicate is null 100 * @throws IllegalArgumentException if the collection ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found