Skip to content

querying by association in @Embeddable doesnt work #199

@fekynko

Description

@fekynko

when i got @ManyToOne field in @Embeddable class:

@Embeddable
public class AddressEntity {

    @ManyToOne
    private City city;

with model like

@Entity
public class AddressHistoryEntity {

    @Embedded
    AddressEntity invoiceAddress;
@Entity
public class AccountEntity {

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "account")
    private List<AddressHistoryEntity> addressHistory = new ArrayList<>();

quering by attribute on association field in embedable class

List<AccountEntity> result = accountRepository.findAll(RSQLJPASupport.rsql("addressHistory.invoiceAddress.city.name=='Praha'"));

fails with

java.lang.ClassCastException: class org.hibernate.query.sqm.tree.domain.SqmEmbeddedValuedSimplePath cannot be cast to class jakarta.persistence.criteria.From (org.hibernate.query.sqm.tree.domain.SqmEmbeddedValuedSimplePath and jakarta.persistence.criteria.From are in unnamed module of loader 'app')

	at io.github.perplexhub.rsql.RSQLJPAPredicateConverter.join(RSQLJPAPredicateConverter.java:201)
	at io.github.perplexhub.rsql.RSQLJPAPredicateConverter.findPropertyPathInternal(RSQLJPAPredicateConverter.java:151)

this can be fixed by "joing" embedded property.

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