Skip to content

CriteriaQuery: not an entity class in db-examplejpa #46

@guillaumefgn

Description

@guillaumefgn

Hello @cschneider ,

I tried your project db-examplejpa which works fine (I have just link this example with a Oracle DB instead of H2 DB). I can add, list and delete persons.

For the "list" action, I tried to rewrite the query to use the Criteria API as follow:

	public List<Person> getAll() {

		final CriteriaBuilder builder = em.getCriteriaBuilder();

		final CriteriaQuery<Person> criteria = builder.createQuery(Person.class);
		final Root<Person> personRoot = criteria.from(Person.class);
		criteria.select(personRoot);

		final TypedQuery<Person> query = em.createQuery(criteria);
		final List<Person> people = query.getResultList();

		return people;
		// return em.createQuery("select p from Person p",
		// Person.class).getResultList();
	}

But I have the following error:

karaf@root>person:list
Error executing command: Not an entity: class net.lr.tutorial.karaf.db.examplejpa.Person

Do you have an idea why?

I am using Karaf 4.0.9.

Thanks a lot.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions