How to write predicate having equal filter with DiscriminatorValue

After upgrading to spring framework 6, hibernate 6.x. we are seeing an issue and not getting a proper solution for it.

Brief about the issue:
We have 3 persistent entity,

  1. DocumentBaseLite (using below annotation)
    @DiscriminatorColumn(name = "ENT_TYPE", discriminatorType = DiscriminatorType.INTEGER, columnDefinition = "int")

  2. Document (using the below annotation)
    @DiscriminatorValue(value="1")

  3. Project (using the below annotation)
    @DiscriminatorValue(value="2")

We are fetching from DocumentBaseLite and I want to filter the result using the discriminatorValue.

my old code -
Predicate predicate = cb.equal(root.type(),
persistentEntityClass); jpaCriteriaBuilder.addPredicate(predicate);

I am passing the persistentEntityClass as Document.class

Error faced : HHH000099: an assertion failure occurred (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session): org.hibernate.AssertionFailure: Unrecognized entity name: com.pkg.service.s1.persistence.entity.Document

Requirement - Please let us know, how to fix this?

Any workaround?

The error is pretty self explanatory: apparently the class com.informatica.service.frs.persistence.entity.Document is not an entity type. You can only compare an entity type to another entity type, so comparison validation is failing.

Is Document a mapped entity type? And is it a subclass of the entity that you’re trying to filter in your query? Maybe show the complete mappings of your inheritance hierarchy types that use discriminators.

@Entity
@DiscriminatorValue(value=FRSConstants.ENT_DOCUMENT_TYPE)
@EdmEntityMapping(entityType="Document", entitySet = "Documents", persistentEntity=Document.class)
public class Document extends DocumentBase {
}

Document is not a mapped entity class but its parent class is “DocumentBase”.

Tried to explain the relation using a diagram.
relation

You can’t compare any subclass of DocumentBase using the discriminator condition, the subtype itself must also be a mapped entity type. From the code excerpt you pasted here, though, it looks like the Doument class is annotated @Entity - I think bot that and Project should be part of your mappings.