Skip to content

ClassCastException #2598

@onacit

Description

@onacit

Describe the bug
A clear and concise description of what the bug is.
Useful resources are

  • Log messages
  • Stack trace
java.lang.ClassCastException: class org.eclipse.persistence.internal.jpa.querydef.ExpressionImpl cannot be cast to class org.eclipse.persistence.internal.jpa.querydef.PathImpl (org.eclipse.persistence.internal.jpa.querydef.ExpressionImpl and org.eclipse.persistence.internal.jpa.querydef.PathImpl are in unnamed module of loader 'app')

	at org.eclipse.persistence.internal.jpa.querydef.CriteriaQueryImpl.createCompoundQuery(CriteriaQueryImpl.java:545)
	at org.eclipse.persistence.internal.jpa.querydef.CriteriaQueryImpl.getDatabaseQuery(CriteriaQueryImpl.java:445)
	at org.eclipse.persistence.internal.jpa.querydef.CriteriaQueryImpl.translate(CriteriaQueryImpl.java:812)
	at org.eclipse.persistence.internal.jpa.querydef.CriteriaQueryImpl.translate(CriteriaQueryImpl.java:801)
	at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1768)
	at com.github.jinahya.oracle.sample.schemas.persistence.hr.Employee_PersistenceIT$SelectManagersAndNumberOfSubordinates__OrderByNumberOfSubordinatesAsc_Test.lambda$CriteriaApi__$3(Employee_PersistenceIT.java:88)
	at com.github.jinahya.persistence.mapped.test.__MappedEntity_Persistence_.lambda$applyEntityManager$0(__MappedEntity_Persistence_.java:257)
	at com.github.jinahya.persistence.mapped.test.__MappedEntity_Persistence_.applyEntityManagerFactory(__MappedEntity_Persistence_.java:200)
	at com.github.jinahya.persistence.mapped.test.__MappedEntity_Persistence_.applyEntityManager(__MappedEntity_Persistence_.java:255)
	at com.github.jinahya.oracle.sample.schemas.persistence.hr.Employee_PersistenceIT.access$100(Employee_PersistenceIT.java:14)
	at com.github.jinahya.oracle.sample.schemas.persistence.hr.Employee_PersistenceIT$SelectManagersAndNumberOfSubordinates__OrderByNumberOfSubordinatesAsc_Test.CriteriaApi__(Employee_PersistenceIT.java:73)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
  • Heap dump or some Java object histogram

To Reproduce
Steps/resources to reproduce the behavior:

  • EclipseLink version: 5.0.0-B11
  • Temurin 25
  • Entity source (mainly applied annotations)
    @OneToMany(mappedBy = MappedEmployee.ATTRIBUTE_NAME_MANAGER,
               fetch = FetchType.LAZY,
               cascade = {
               },
               orphanRemoval = false
    )
    private List<@Valid @NotNull Employee> subordinates;
  1. For problem in persistence (JPA)
    • JPA context like persistence.xml settings or related system properties (in case of JPA)
    • Database provider/version
    • JDBC driver provider/version (it should be useful if bug is related with some "specific" datatype e.g. JSON)
  2. For problem in MOXy (JAXB implementation)
    • JAXBContext creation (in case of MOXy)
  • Other context description in case of SDO, DBWS or others
  • Other additional context like AspectJ pre-compiler, Spring FW, JEE Server, Lombok annotations....
  • Code example which leads into bug like:
...
EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("test-jpa-pu");
EntityManager em = entityManagerFactory.createEntityManager();
em.getTransaction().begin();
TestEntityMaster entity = new TestEntityMaster(10, "Persist Master 1");
em.persist(entity);
em.getTransaction().commit();
...

Expected behavior
A clear and concise description of what you expected to happen.

Additional context
Add any other context about the problem here.

Note
The best way to describe a bug is to give us a test case.
To simplify this process there are Maven archetypes in etc/archetypes/bug_test_case project directory which can be built locally by "mvn install".
Initial test project can then be generated from these archetypes by:

mvn archetype:generate -DarchetypeGroupId=org.eclipse.persistence -DarchetypeArtifactId=org.eclipse.persistence.bug.jpa-archetype -DarchetypeVersion=5.0.0-SNAPSHOT -DgroupId=eclipselink.bug.testcase -DartifactId=jpa-testcase

mvn archetype:generate -DarchetypeGroupId=org.eclipse.persistence -DarchetypeArtifactId=org.eclipse.persistence.bug.moxy-archetype -DarchetypeVersion=5.0.0-SNAPSHOT -DgroupId=eclipselink.bug.testcase -DartifactId=moxy-testcase

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions