Skip to content

Commit

Permalink
#92 - Upgraded Hibernate version from 6.1.5 5o 6.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
starnowski committed Dec 28, 2023
1 parent 07d0675 commit a5c4fa3
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 33 deletions.
2 changes: 1 addition & 1 deletion hibernate6-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<artifactId>hibernate6-core</artifactId>

<properties>
<org.hibernate.hibernate.core.version>6.1.5.Final</org.hibernate.hibernate.core.version>
<org.hibernate.hibernate.core.version>6.4.0.Final</org.hibernate.hibernate.core.version>
<java.version>11</java.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public CastOperatorFunctionDescriptor(HibernateContext hibernateContext) {
}

@Override
public void render(SqlAppender sqlAppender, List<? extends SqlAstNode> sqlAstArguments, SqlAstTranslator<?> translator) {
public void render(SqlAppender sqlAppender, List<? extends SqlAstNode> sqlAstArguments, ReturnableType<?> returnableType, SqlAstTranslator<?> translator) {
//TODO Check if sqlAstArguments has two arguments only!
boolean firstPass = true;
for (Iterator var11 = sqlAstArguments.iterator(); var11.hasNext(); firstPass = false) {
Expand All @@ -52,7 +52,7 @@ public void render(SqlAppender sqlAppender, List<? extends SqlAstNode> sqlAstArg
}

@Override
protected <T> SelfRenderingSqmFunction<T> generateSqmFunctionExpression(List<? extends SqmTypedNode<?>> arguments, ReturnableType<T> impliedResultType, QueryEngine queryEngine, TypeConfiguration typeConfiguration) {
protected <T> SelfRenderingSqmFunction<T> generateSqmFunctionExpression(List<? extends SqmTypedNode<?>> arguments, ReturnableType<T> impliedResultType, QueryEngine queryEngine) {
List<SqmExpression<String>> args = new ArrayList<>();
//TODO Check if arguments has two arguments only!
for (int i = 0; i < arguments.size(); i++) {
Expand Down
2 changes: 1 addition & 1 deletion hibernate6/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<artifactId>hibernate6</artifactId>

<properties>
<org.hibernate.hibernate.core.version>6.1.5.Final</org.hibernate.hibernate.core.version>
<org.hibernate.hibernate.core.version>6.4.0.Final</org.hibernate.hibernate.core.version>
<java.version>11</java.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
package com.github.starnowski.posjsonhelper.hibernate6;

import jakarta.persistence.criteria.Path;
import org.hibernate.query.criteria.JpaExpression;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.function.FunctionRenderer;
import org.hibernate.query.sqm.function.FunctionRenderingSupport;
import org.hibernate.query.sqm.function.SelfRenderingSqmFunction;
import org.hibernate.query.sqm.produce.function.StandardFunctionReturnTypeResolvers;
Expand Down Expand Up @@ -65,7 +67,7 @@ public AbstractJsonBExtractPath(Path referencedPathSource, NodeBuilder nodeBuild

public AbstractJsonBExtractPath(Path referencedPathSource, List<? extends SqmTypedNode<?>> path, NodeBuilder nodeBuilder, String functionName) {
super(nodeBuilder.getQueryEngine().getSqmFunctionRegistry().findFunctionDescriptor(functionName),
(FunctionRenderingSupport) nodeBuilder.getQueryEngine().getSqmFunctionRegistry().findFunctionDescriptor(functionName),
(FunctionRenderer) nodeBuilder.getQueryEngine().getSqmFunctionRegistry().findFunctionDescriptor(functionName),
contactParameters(referencedPathSource, (List<? extends SqmTypedNode<?>>) path),
null,
null,
Expand All @@ -79,7 +81,7 @@ private static List<? extends SqmTypedNode<?>> mapPathParameters(NodeBuilder nod
throw new IllegalArgumentException("Path argument can not be null or empty list");
}
List<SqmTypedNode<?>> result = new ArrayList<>();
result.addAll(path.stream().map(p -> nodeBuilder.value(p)).collect(Collectors.toList()));
result.addAll(path.stream().map(p -> (SqmTypedNode<String>)nodeBuilder.value(p)).collect(Collectors.toList()));
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public AbstractJsonbArrayStringsExistPredicateDescriptor(String name, HibernateC
abstract public String getSqmFunction();

@Override
protected <T> SelfRenderingSqmFunction<T> generateSqmFunctionExpression(List<? extends SqmTypedNode<?>> arguments, ReturnableType<T> impliedResultType, QueryEngine queryEngine, TypeConfiguration typeConfiguration) {
protected <T> SelfRenderingSqmFunction<T> generateSqmFunctionExpression(List<? extends SqmTypedNode<?>> arguments, ReturnableType<T> impliedResultType, QueryEngine queryEngine) {
return generateJsonbArrayStringsExistPredicate(this.hibernateContext, queryEngine.getCriteriaBuilder(), (JsonBExtractPath) arguments.get(0), (JsonArrayFunction) arguments.get(1));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.github.starnowski.posjsonhelper.core.HibernateContext;
import com.github.starnowski.posjsonhelper.hibernate6.operators.JsonArrayFunction;
import org.hibernate.query.ReturnableType;
import org.hibernate.query.criteria.JpaExpression;
import org.hibernate.query.spi.QueryEngine;
import org.hibernate.query.sqm.function.AbstractSqmSelfRenderingFunctionDescriptor;
import org.hibernate.query.sqm.function.SelfRenderingSqmFunction;
Expand Down Expand Up @@ -64,7 +65,7 @@ public JsonArrayFunctionDescriptor(HibernateContext hibernateContext) {
}

@Override
public void render(SqlAppender sqlAppender, List<? extends SqlAstNode> sqlAstArguments, SqlAstTranslator<?> translator) {
public void render(SqlAppender sqlAppender, List<? extends SqlAstNode> sqlAstArguments, ReturnableType<?> returnableType, SqlAstTranslator<?> translator) {
sqlAppender.appendSql(this.getName());
sqlAppender.appendSql("[");

Expand All @@ -81,7 +82,7 @@ public void render(SqlAppender sqlAppender, List<? extends SqlAstNode> sqlAstArg
}

@Override
protected <T> SelfRenderingSqmFunction<T> generateSqmFunctionExpression(List<? extends SqmTypedNode<?>> arguments, ReturnableType<T> impliedResultType, QueryEngine queryEngine, TypeConfiguration typeConfiguration) {
protected <T> SelfRenderingSqmFunction<T> generateSqmFunctionExpression(List<? extends SqmTypedNode<?>> arguments, ReturnableType<T> impliedResultType, QueryEngine queryEngine) {
List<SqmExpression<String>> args = new ArrayList<>();
for (int i = 0; i < arguments.size(); i++) {
args.add((SqmExpression<String>) arguments.get(i));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
package com.github.starnowski.posjsonhelper.hibernate6.operators;

import com.github.starnowski.posjsonhelper.core.HibernateContext;
import org.hibernate.query.criteria.JpaExpression;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.function.FunctionRenderer;
import org.hibernate.query.sqm.function.FunctionRenderingSupport;
import org.hibernate.query.sqm.function.SelfRenderingSqmFunction;
import org.hibernate.query.sqm.produce.function.StandardFunctionReturnTypeResolvers;
Expand All @@ -41,7 +43,7 @@ public class JsonArrayFunction extends SelfRenderingSqmFunction<String> implemen

public JsonArrayFunction(NodeBuilder nodeBuilder, List<SqmExpression<String>> arguments, HibernateContext hibernateContext) {
super(nodeBuilder.getQueryEngine().getSqmFunctionRegistry().findFunctionDescriptor(hibernateContext.getJsonFunctionJsonArrayOperator()),
(FunctionRenderingSupport) nodeBuilder.getQueryEngine().getSqmFunctionRegistry().findFunctionDescriptor(hibernateContext.getJsonFunctionJsonArrayOperator()),
(FunctionRenderer) nodeBuilder.getQueryEngine().getSqmFunctionRegistry().findFunctionDescriptor(hibernateContext.getJsonFunctionJsonArrayOperator()),
arguments,
null,
null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
/**
* Posjsonhelper library is an open-source project that adds support of
* Hibernate query for https://www.postgresql.org/docs/10/functions-json.html)
*
* Copyright (C) 2023 Szymon Tarnowski
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
* Posjsonhelper library is an open-source project that adds support of
* Hibernate query for https://www.postgresql.org/docs/10/functions-json.html)
* <p>
* Copyright (C) 2023 Szymon Tarnowski
* <p>
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* <p>
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* <p>
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/
package com.github.starnowski.posjsonhelper.hibernate6.predicates;

import com.github.starnowski.posjsonhelper.core.HibernateContext;
import com.github.starnowski.posjsonhelper.hibernate6.JsonBExtractPath;
import com.github.starnowski.posjsonhelper.hibernate6.operators.JsonArrayFunction;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.function.FunctionRenderingSupport;
import org.hibernate.query.sqm.function.FunctionRenderer;
import org.hibernate.query.sqm.function.SelfRenderingSqmFunction;
import org.hibernate.query.sqm.produce.function.StandardFunctionReturnTypeResolvers;
import org.hibernate.query.sqm.tree.SqmCopyContext;
import org.hibernate.query.sqm.tree.expression.SqmExpression;
import org.hibernate.type.StandardBasicTypes;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
Expand Down Expand Up @@ -70,7 +71,7 @@ public AbstractJsonbArrayStringsExistPredicate(HibernateContext context, NodeBui

public AbstractJsonbArrayStringsExistPredicate(HibernateContext context, NodeBuilder nodeBuilder, JsonBExtractPath jsonBExtractPath, JsonArrayFunction arrayFunction, String functionName) {
super(nodeBuilder.getQueryEngine().getSqmFunctionRegistry().findFunctionDescriptor(functionName),
(FunctionRenderingSupport) nodeBuilder.getQueryEngine().getSqmFunctionRegistry().findFunctionDescriptor(functionName),
(FunctionRenderer) nodeBuilder.getQueryEngine().getSqmFunctionRegistry().findFunctionDescriptor(functionName),
parameters(jsonBExtractPath, arrayFunction),
null,
null,
Expand All @@ -94,7 +95,7 @@ private static JsonArrayFunction mapArrayValues(NodeBuilder nodeBuilder, Hiberna
throw new IllegalArgumentException("Values can not be null or empty list");
}
List<SqmExpression<String>> arrayArguments = new ArrayList<>();
arrayArguments.addAll(Stream.of(values).map(p -> nodeBuilder.value(p)).collect(Collectors.toList()));
arrayArguments.addAll(Stream.of(values).map(p -> (SqmExpression<String>)nodeBuilder.value(p)).collect(Collectors.toList()));
JsonArrayFunction jsonArrayFunction = new JsonArrayFunction(nodeBuilder, arrayArguments, context);
return jsonArrayFunction;
}
Expand Down
2 changes: 1 addition & 1 deletion text/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</modules>

<properties>
<org.hibernate.hibernate.core.version>6.1.5.Final</org.hibernate.hibernate.core.version>
<org.hibernate.hibernate.core.version>6.4.0.Final</org.hibernate.hibernate.core.version>
<java.version>11</java.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
Expand Down

0 comments on commit a5c4fa3

Please sign in to comment.