Closed AlexSischin closed 3 weeks ago
This looks correct to me. Do you think you could provide a reproducer for this?
This looks correct to me. Do you think you could provide a reproducer for this?
Ok, I will try in a few days
This looks correct to me. Do you think you could provide a reproducer for this?
Here is the reproducer based on the Spring Boot template. You will have to create a local Postgres database for it.
I've finally made it work! I'm so sorry for wasting your time... The second mentioned specification was totally correct:
root.get("id").in(
cb.function(
"GET_OBJECTS_BY_PARENTS",
List.class, // this should be UUID.class, but both work
cb.literal(parents)
)
);
The exception No object leaf allowed but model is an object leaf
was actually due to Pageable had a sort by a ManyToOne property. I just removed it.
And also I had to change the return type for my Jpql function (it was a List):
public class GetObjectsByParentsFunction implements JpqlFunction {
@Override
public boolean hasArguments() {
return true;
}
@Override
public boolean hasParenthesesIfNoArguments() {
return true;
}
@Override
public Class<?> getReturnType(Class<?> firstArgClass) {
return UUID.class;
}
@Override
public void render(FunctionRenderContext context) {
context.addChunk("SELECT id FROM get_objects_by_parents(");
context.addArgument(0);
context.addChunk(")");
}
}
So, even though Hibernate worked before somehow, the code had some issues that should have been addressed anyway. Apologies for a false alarm
Glad it worked out for you!
Description
Hi! I'm new to this amazing library and I'm stuck upon an issue. Not sure whether this should be a bug or a question.
I'm trying to integrate blaze persistence in an existing project that uses Criteria API with Spring Specifications like this:
This function encapsulates some complex JSON processing logic. After I imported blaze-persistence and configured it, this stopped working.
Expected behavior
Legacy Specifications that use CriteriaBuilder#function work.
Actual behavior
The following error occurs:
Steps to reproduce
Imports:
Config:
What I've tried
I've tried to create a jpql function:
register it like this:
and use it like this:
This doesn't work either. I get another error:
I've also heard about
.isExpression
thing, but don't get how to use it in a Specification.The only option I currently see is to invoke this function using plain JDBC and then paste the results in a simple
.in
expression, but this would create a significant overhead.Environment
Version: 1.6.12 JPA-Provider: Hibernate 5.6.15 DBMS: PostgreSQL 14.7 Application Server: Java SE