Renet
Renet

Reputation: 349

Apache displaying old error with Java

I have ran into a problem with Java and Apache. Before I used JDBC and now converted to JPA, I'm working on a small project to get into all of it. I have a page that displays people and also you can filter the list with a search bar.

The problem is when I run Apache and try to filter the list with the search bar, it displays an old error, which I have changed multiple times.

public static List<Person> search(String search) {
        EntityManager em = null;
        try {
            em = JpaUtil.getFactory().createEntityManager();

            TypedQuery<Person> query = em.createQuery("select p from Person p where upper(p.first_name) like upper('%" + search + "%')", Person.class);

            return query.getResultList();
        } finally {
            JpaUtil.closeQuietly(em);
        }
    }

But I get an Apache error that reads:

org.hibernate.QueryException: expecting ''', found '<EOF>' [select * from customer where upper(first_name) like upper('%%') or upper(surname) like upper('%%'')]

Which is my old code, what am I missing? I've checked all my code and cant seem to find the reason why the old part keeps showing up as an error.

Upvotes: 0

Views: 114

Answers (2)

Renet
Renet

Reputation: 349

I have discovered what the problem was, I deleted my ivy.jar and put it back again. That fixed the problem for me. Good luck to anyone with this problem!

Upvotes: 1

K1A
K1A

Reputation: 33

you should Use placeholders

there is a question that look like your problem so i think it may helps you:

QueryException in Hibernate because of apostrophe

Upvotes: 1

Related Questions