Blazebit / blaze-persistence

Rich Criteria API for JPA providers
https://persistence.blazebit.com
Apache License 2.0
741 stars 90 forks source link

"No viable alternative at input" error near 'entity_function' #1907

Open Pilpin opened 5 months ago

Pilpin commented 5 months ago

Description

Hello, I have and @Entity A with a property x which is a set of an other @Entity B, both entites have an @EntityView Av and Bv. In Av I have a property mapping to b but with a @Limit set to one

@Entity
public class A {
  public Set<B> b;
}

@Entity B {
  public SomeType someProp;
}

@EntityView(A.class)
public interface Av {
  @IdMapping
  Long getId();

  [... some props ...]

  @Mapping("b")
  @Limit(limit = "1", order = {"someProp ASC"})
  Bv getBView();
}

@EntityView(B.class)
public interface Bv {
  @IdMapping
  Long getId();

  [... some props ...]

  SomeType getSomeProp();
}

When executing a paged query like such

{
  var cb = cbf.create(entityManager, A.class);
  var setting = EntityViewSetting.create(Av.class, 0, 20);
  setting.addAttributeSorter("bView.someProp", Sorters.descending());
  setting.addAttributeSorter("id", Sorters.ascending());
  PagedList<Av> list = evm.applySetting(setting, cb).getResultList();
[...]
}

I get an At 1:1759 and token 'entity_function', no viable alternative at input error and the character number specified is this *entity_function with the surrounding characters being ... WHERE a.id IN *entity_function((SELECT a.id ...

I wonder if this *entity_function makes sense, it appears further in the query but without the *, I don't understand what the star means here, but perhaps it is "just" a concatenation issue ? Does this make sense ?

Thank you.

Environment

Version: 1.6.11 Quarkus 3.10.1 Hibernate 6.4.7.Final Postgresql 16

beikov commented 3 months ago

Please provide a reproducer for this bug e.g. based on our quickstarts.