2

I have an entity Person with fields String name and String designation. When I tried to query using Eclipselink ExpressionBuilder, as:

    Project project=new Project();
    Login login=new DatabaseLogin();
    login.setUserName("root");
    login.setPassword("root");
    project.setLogin(login);
    DatabaseSession session=project.createDatabaseSession();

    ExpressionBuilder expBuilder=new ExpressionBuilder();
    Expression expression=expBuilder.get("name").equalsIgnoreCase("SomeName");
    Vector readAllObjects = session.readAllObjects(Person.class, expression);

On executing last statement the following exception is thrown :

Exception [EclipseLink-6007] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.QueryException Exception Description: Missing descriptor for [class com.mycompany.entity.Person]. Query: ReadAllQuery(referenceClass=Person)

What might be the reason? Thanks in advance...

Naveed S
  • 5,106
  • 4
  • 34
  • 52

2 Answers2

1

At last I got it. Instead of DatabaseSession, org.eclipse.persistence.sessions.server.ClientSession had to be used.

    JpaEntityManager jpaEntityManager=em.unwrap(JpaEntityManager.class);
    ClientSession session=jpaEntityManager.getServerSession().acquireClientSession();

    ExpressionBuilder expBuilder=new ExpressionBuilder();
    Expression expression=expBuilder.get("name").equalsIgnoreCase("SomeName");
    Vector readAllObjects = session.readAllObjects(Person.class, expression);

em is the EntityManager.

This solved the issue.

Naveed S
  • 5,106
  • 4
  • 34
  • 52
0

You did not add a descriptor for Person. You need to map it to be able to query it.

Also consider using JPA.

James
  • 17,965
  • 11
  • 91
  • 146