From d98b45e32f3b0ed96027dc47441649391f8f5b25 Mon Sep 17 00:00:00 2001 From: starnowski <33316705+starnowski@users.noreply.github.com> Date: Sun, 12 Oct 2025 21:51:46 +0200 Subject: [PATCH 01/23] #158 - Added tests entity [skip ci] --- .../text/hibernate6/model/Item.java | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/model/Item.java diff --git a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/model/Item.java b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/model/Item.java new file mode 100644 index 00000000..d939f81c --- /dev/null +++ b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/model/Item.java @@ -0,0 +1,62 @@ +package com.github.starnowski.posjsonhelper.text.hibernate6.model; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; + +@Entity +@Table(name = "item") +public class Item { + + @Id + private Long id; + @Column(name = "short_name") + private String shortName; + @Column(name = "full_name") + private String fullName; + @Column(name = "short_description") + private String shortDescription; + @Column(name = "full_description") + private String fullDescription; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getShortName() { + return shortName; + } + + public void setShortName(String shortName) { + this.shortName = shortName; + } + + public String getFullName() { + return fullName; + } + + public void setFullName(String fullName) { + this.fullName = fullName; + } + + public String getShortDescription() { + return shortDescription; + } + + public void setShortDescription(String shortDescription) { + this.shortDescription = shortDescription; + } + + public String getFullDescription() { + return fullDescription; + } + + public void setFullDescription(String fullDescription) { + this.fullDescription = fullDescription; + } +} From a517e00bad5e791e69484419ab3633a0b69f14a9 Mon Sep 17 00:00:00 2001 From: starnowski <33316705+starnowski@users.noreply.github.com> Date: Tue, 14 Oct 2025 21:24:04 +0200 Subject: [PATCH 02/23] #158 - Added limits for columns [skip ci] --- .../posjsonhelper/text/hibernate6/model/Item.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/model/Item.java b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/model/Item.java index d939f81c..2f23205a 100644 --- a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/model/Item.java +++ b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/model/Item.java @@ -11,13 +11,13 @@ public class Item { @Id private Long id; - @Column(name = "short_name") + @Column(name = "short_name", length = 75) private String shortName; - @Column(name = "full_name") + @Column(name = "full_name", length = 150) private String fullName; - @Column(name = "short_description") + @Column(name = "short_description", length = 255) private String shortDescription; - @Column(name = "full_description") + @Column(name = "full_description", length = 512) private String fullDescription; public Long getId() { From bf7da648312d6861489222931e502e133649cd7c Mon Sep 17 00:00:00 2001 From: starnowski <33316705+starnowski@users.noreply.github.com> Date: Wed, 15 Oct 2025 01:00:15 +0200 Subject: [PATCH 03/23] #158 - Added tests data (not yet finisehd) [skip ci] --- .../text/hibernate6/dao/items.sql | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 text/hibernate6-text-tests/src/test/resources/com/github/starnowski/posjsonhelper/text/hibernate6/dao/items.sql diff --git a/text/hibernate6-text-tests/src/test/resources/com/github/starnowski/posjsonhelper/text/hibernate6/dao/items.sql b/text/hibernate6-text-tests/src/test/resources/com/github/starnowski/posjsonhelper/text/hibernate6/dao/items.sql new file mode 100644 index 00000000..e01e3188 --- /dev/null +++ b/text/hibernate6-text-tests/src/test/resources/com/github/starnowski/posjsonhelper/text/hibernate6/dao/items.sql @@ -0,0 +1,21 @@ +INSERT INTO item (id, short_name, full_name, full_description, short_description) +VALUES + ( + 1, + 'XDeep Stealth 2.0 TEC Setup', + 'XDeep Stealth 2.0 TEC Setup Sidemount BCD System', + 'The STEALTH 2.0 TEC was designed to excel in deep decompression diving and in extended cave penetrations. It provides 19 kg of lift, supports multiple cylinders, and features a centred dump valve so you can release gas with either hand while maintaining trim. The harness uses multi-thickness webbing, modular weight placement up to 25 kg, and a streamlined wing fixed to the harness for stability. Optional RB (redundant bladder) version includes dual wings in one slim package. The system includes the STEALTH 2.0 harness, modular central weight pocket, and BCD wing mounted to the harness. (Dry weight: ~2.8 kg)', + 'STEALTH 2.0 sidemount BCD system with 19 kg lift, modular weight, and integrated wing.' + ); +INSERT INTO item (id, short_name, full_name, full_description, short_description) +VALUES + ( + 2, + 'XDeep ZEOS 28 Deluxe', + 'XDeep ZEOS 28 Deluxe Aluminium Backplate M Weight Pockets Wing', + 'The ZEOS 28 Deluxe system from XDeep is a high-performance single-tank wing / backplate setup, offering 13 kg (28 lb) lift, modular weight pockets (0 to ~16 kg), and durable materials (Cordura 1100dTEX outer shell, nylon/TPU inner bladder). The aluminium backplate option yields lower weight for travel use, while the 3D mesh padding on harness and backplate enhances comfort and stability. The wing is a double-shell toroidal (“donut”) style providing balanced trim and buoyancy control, and the modular system allows flexible weight distribution for warm or cold water use. The harness features ITW Nexus QR buckles, and the system is adjustable to diverse body shapes. (Dry BCD weight ~1.05 kg; full set without weight pockets ~3.5 kg) ', + 'Single-tank wing/backplate system (13 kg lift) with aluminium backplate, modular weight pockets, and 3D mesh harness for comfort.' + ); + + + From e9bf2d47f2bf7f0163e22533a6d8a7105d031ca0 Mon Sep 17 00:00:00 2001 From: starnowski <33316705+starnowski@users.noreply.github.com> Date: Fri, 17 Oct 2025 23:00:49 +0200 Subject: [PATCH 04/23] #158 - Added tests case [skip ci] --- .../text/hibernate6/Application.java | 1 + .../text/hibernate6/dao/ItemDao.java | 23 +++++++++ .../text/hibernate6/dao/ItemDaoTest.java | 48 +++++++++++++++++++ .../text/hibernate6/model/Item.java | 2 +- .../text/hibernate6/dao/clean-database.sql | 3 +- 5 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java create mode 100644 text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDaoTest.java diff --git a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/Application.java b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/Application.java index 23d0f5b3..e9d3dcb4 100644 --- a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/Application.java +++ b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/Application.java @@ -11,6 +11,7 @@ public class Application { public static final String CLEAR_DATABASE_SCRIPT_PATH = "clean-database.sql"; public static final String TWEETS_SCRIPT_PATH = "tweets.sql"; public static final String TWEETS_WITH_LOCALE_SCRIPT_PATH = "tweets-with-locale.sql"; + public static final String ITEMS_SCRIPT_PATH = "items.sql"; public static final String TEXT_INDEX_SCRIPT_PATH = "text-index.sql"; public static final String ENGLISH_CONFIGURATION = "english"; public static final String POLISH_CONFIGURATION = "pl_ispell"; diff --git a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java new file mode 100644 index 00000000..03175975 --- /dev/null +++ b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java @@ -0,0 +1,23 @@ +package com.github.starnowski.posjsonhelper.text.hibernate6.dao; + +import com.github.starnowski.posjsonhelper.core.HibernateContext; +import com.github.starnowski.posjsonhelper.text.hibernate6.model.Item; +import jakarta.persistence.EntityManager; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public class ItemDao { + + @Autowired + private EntityManager entityManager; + @Autowired + private HibernateContext hibernateContext; + + + public List findItemsByQuery(String phrase) { + return null; + } +} diff --git a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDaoTest.java b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDaoTest.java new file mode 100644 index 00000000..37e3a799 --- /dev/null +++ b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDaoTest.java @@ -0,0 +1,48 @@ +package com.github.starnowski.posjsonhelper.text.hibernate6.dao; + +import com.github.starnowski.posjsonhelper.text.hibernate6.model.Item; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.jdbc.Sql; +import org.springframework.test.context.jdbc.SqlConfig; + +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static com.github.starnowski.posjsonhelper.text.hibernate6.Application.*; +import static java.util.Arrays.asList; +import static org.junit.jupiter.api.Assertions.*; +import static org.springframework.test.context.jdbc.Sql.ExecutionPhase.BEFORE_TEST_METHOD; +import static org.springframework.test.context.jdbc.SqlConfig.TransactionMode.ISOLATED; + +class ItemDaoTest extends AbstractItTest { + + @Autowired + private ItemDao itemDao; + + + private static Stream provideShouldFindCorrectItemWithOrderBasedOnPhrase() { + return Stream.of( + Arguments.of("wing", asList(1L, 2L)) + ); + } + + @Sql(value = {CLEAR_DATABASE_SCRIPT_PATH, ITEMS_SCRIPT_PATH}, + config = @SqlConfig(transactionMode = ISOLATED), + executionPhase = BEFORE_TEST_METHOD) + @DisplayName("should find correct item with order based on phrase") + @ParameterizedTest + @MethodSource("provideShouldFindCorrectItemWithOrderBasedOnPhrase") + public void shouldFindCorrectItemWithOrderBasedOnPhrase(String phrase, List expectedIds) { + // WHEN + List items = itemDao.findItemsByQuery(phrase); + + // THEN + assertEquals(expectedIds, items.stream().map(Item::getId).toList()); + } +} \ No newline at end of file diff --git a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/model/Item.java b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/model/Item.java index 2f23205a..488254d9 100644 --- a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/model/Item.java +++ b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/model/Item.java @@ -17,7 +17,7 @@ public class Item { private String fullName; @Column(name = "short_description", length = 255) private String shortDescription; - @Column(name = "full_description", length = 512) + @Column(name = "full_description", length = 1024) private String fullDescription; public Long getId() { diff --git a/text/hibernate6-text-tests/src/test/resources/com/github/starnowski/posjsonhelper/text/hibernate6/dao/clean-database.sql b/text/hibernate6-text-tests/src/test/resources/com/github/starnowski/posjsonhelper/text/hibernate6/dao/clean-database.sql index 0e5e2582..c664ce94 100644 --- a/text/hibernate6-text-tests/src/test/resources/com/github/starnowski/posjsonhelper/text/hibernate6/dao/clean-database.sql +++ b/text/hibernate6-text-tests/src/test/resources/com/github/starnowski/posjsonhelper/text/hibernate6/dao/clean-database.sql @@ -1,2 +1,3 @@ TRUNCATE tweet CASCADE; -TRUNCATE tweet_with_locale CASCADE; \ No newline at end of file +TRUNCATE tweet_with_locale CASCADE; +TRUNCATE item CASCADE; \ No newline at end of file From 26174934eb88c049654e6703d9632cef35f8e456 Mon Sep 17 00:00:00 2001 From: starnowski <33316705+starnowski@users.noreply.github.com> Date: Fri, 17 Oct 2025 23:13:51 +0200 Subject: [PATCH 05/23] #158 - Added implementation (not yet finished) [skip ci] --- .../text/hibernate6/dao/ItemDao.java | 56 ++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java index 03175975..6084accf 100644 --- a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java +++ b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java @@ -3,6 +3,7 @@ import com.github.starnowski.posjsonhelper.core.HibernateContext; import com.github.starnowski.posjsonhelper.text.hibernate6.model.Item; import jakarta.persistence.EntityManager; +import jakarta.persistence.criteria.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; @@ -18,6 +19,59 @@ public class ItemDao { public List findItemsByQuery(String phrase) { - return null; + CriteriaBuilder cb = entityManager.getCriteriaBuilder(); + CriteriaQuery cq = cb.createQuery(Item.class); + Root root = cq.from(Item.class); + + // Build weighted tsvector using posjsonhelper functions + Expression shortNameVec = cb.function("setweight", String.class, + cb.function("to_tsvector", String.class, cb.literal("english"), root.get("shortName")), + cb.literal("A") + ); + + Expression fullNameVec = cb.function("setweight", String.class, + cb.function("to_tsvector", String.class, cb.literal("english"), root.get("fullName")), + cb.literal("B") + ); + + Expression shortDescriptionVec = cb.function("setweight", String.class, + cb.function("to_tsvector", String.class, cb.literal("english"), root.get("shortDescription")), + cb.literal("C") + ); + + Expression fullDescriptionVec = cb.function("setweight", String.class, + cb.function("to_tsvector", String.class, cb.literal("english"), root.get("fullDescription")), + cb.literal("D") + ); + + // Concatenate tsvectors (|| operator) + Expression fullVector = cb.function("tsvector_concat", String.class, + shortNameVec, fullNameVec, shortDescriptionVec, fullDescriptionVec + ); + + // Build tsquery + Expression queryExpr = cb.function( + "plainto_tsquery", String.class, + cb.literal("english"), + cb.literal(phrase) + ); + + // WHERE clause using @@ operator (registered as ts_match) + Predicate matches = cb.isTrue( + cb.function("ts_match", Boolean.class, fullVector, queryExpr) + ); + + cq.where(matches); + + // Ranking + Expression rankExpr = cb.function( + "ts_rank", Double.class, + fullVector, + queryExpr + ); + + cq.orderBy(cb.desc(rankExpr)); + + return entityManager.createQuery(cq).getResultList(); } } From 5fbb5d78f0dcb9ea4d8b9e4e12716c9c36ba8ba8 Mon Sep 17 00:00:00 2001 From: starnowski <33316705+starnowski@users.noreply.github.com> Date: Fri, 17 Oct 2025 23:22:18 +0200 Subject: [PATCH 06/23] #158 - Added implementation (not yet finished) [skip ci] --- .../text/hibernate6/dao/ItemDao.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java index 6084accf..b5e95a1e 100644 --- a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java +++ b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java @@ -1,14 +1,19 @@ package com.github.starnowski.posjsonhelper.text.hibernate6.dao; import com.github.starnowski.posjsonhelper.core.HibernateContext; +import com.github.starnowski.posjsonhelper.text.hibernate6.functions.TSVectorFunction; import com.github.starnowski.posjsonhelper.text.hibernate6.model.Item; +import com.github.starnowski.posjsonhelper.text.hibernate6.operators.RegconfigTypeCastOperatorFunction; import jakarta.persistence.EntityManager; import jakarta.persistence.criteria.*; +import org.hibernate.query.sqm.NodeBuilder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; import java.util.List; +import static com.github.starnowski.posjsonhelper.text.hibernate6.Application.ENGLISH_CONFIGURATION; + @Repository public class ItemDao { @@ -25,22 +30,26 @@ public List findItemsByQuery(String phrase) { // Build weighted tsvector using posjsonhelper functions Expression shortNameVec = cb.function("setweight", String.class, - cb.function("to_tsvector", String.class, cb.literal("english"), root.get("shortName")), + new TSVectorFunction(root.get("shortName"), new RegconfigTypeCastOperatorFunction((NodeBuilder) cb, ENGLISH_CONFIGURATION, hibernateContext), (NodeBuilder) cb), +// cb.function("to_tsvector", String.class, cb.literal("english"), root.get("shortName")), cb.literal("A") ); Expression fullNameVec = cb.function("setweight", String.class, - cb.function("to_tsvector", String.class, cb.literal("english"), root.get("fullName")), + new TSVectorFunction(root.get("fullName"), new RegconfigTypeCastOperatorFunction((NodeBuilder) cb, ENGLISH_CONFIGURATION, hibernateContext), (NodeBuilder) cb), +// cb.function("to_tsvector", String.class, cb.literal("english"), root.get("fullName")), cb.literal("B") ); Expression shortDescriptionVec = cb.function("setweight", String.class, - cb.function("to_tsvector", String.class, cb.literal("english"), root.get("shortDescription")), + new TSVectorFunction(root.get("shortDescription"), new RegconfigTypeCastOperatorFunction((NodeBuilder) cb, ENGLISH_CONFIGURATION, hibernateContext), (NodeBuilder) cb), +// cb.function("to_tsvector", String.class, cb.literal("english"), root.get("shortDescription")), cb.literal("C") ); Expression fullDescriptionVec = cb.function("setweight", String.class, - cb.function("to_tsvector", String.class, cb.literal("english"), root.get("fullDescription")), + new TSVectorFunction(root.get("fullDescription"), new RegconfigTypeCastOperatorFunction((NodeBuilder) cb, ENGLISH_CONFIGURATION, hibernateContext), (NodeBuilder) cb), +// cb.function("to_tsvector", String.class, cb.literal("english"), root.get("fullDescription")), cb.literal("D") ); From 4787b38eaa4ca3a3fd8021a8cbf5c673d61c0e46 Mon Sep 17 00:00:00 2001 From: starnowski <33316705+starnowski@users.noreply.github.com> Date: Sat, 18 Oct 2025 00:02:45 +0200 Subject: [PATCH 07/23] #158 - Added implementation (not yet finished) [skip ci] --- .../text/hibernate6/dao/ItemDao.java | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java index b5e95a1e..ab8583aa 100644 --- a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java +++ b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java @@ -2,11 +2,14 @@ import com.github.starnowski.posjsonhelper.core.HibernateContext; import com.github.starnowski.posjsonhelper.text.hibernate6.functions.TSVectorFunction; +import com.github.starnowski.posjsonhelper.text.hibernate6.functions.WebsearchToTSQueryFunction; import com.github.starnowski.posjsonhelper.text.hibernate6.model.Item; import com.github.starnowski.posjsonhelper.text.hibernate6.operators.RegconfigTypeCastOperatorFunction; +import com.github.starnowski.posjsonhelper.text.hibernate6.operators.TextOperatorFunction; import jakarta.persistence.EntityManager; import jakarta.persistence.criteria.*; import org.hibernate.query.sqm.NodeBuilder; +import org.hibernate.query.sqm.tree.expression.SqmExpression; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; @@ -31,44 +34,32 @@ public List findItemsByQuery(String phrase) { // Build weighted tsvector using posjsonhelper functions Expression shortNameVec = cb.function("setweight", String.class, new TSVectorFunction(root.get("shortName"), new RegconfigTypeCastOperatorFunction((NodeBuilder) cb, ENGLISH_CONFIGURATION, hibernateContext), (NodeBuilder) cb), -// cb.function("to_tsvector", String.class, cb.literal("english"), root.get("shortName")), cb.literal("A") ); Expression fullNameVec = cb.function("setweight", String.class, new TSVectorFunction(root.get("fullName"), new RegconfigTypeCastOperatorFunction((NodeBuilder) cb, ENGLISH_CONFIGURATION, hibernateContext), (NodeBuilder) cb), -// cb.function("to_tsvector", String.class, cb.literal("english"), root.get("fullName")), cb.literal("B") ); Expression shortDescriptionVec = cb.function("setweight", String.class, new TSVectorFunction(root.get("shortDescription"), new RegconfigTypeCastOperatorFunction((NodeBuilder) cb, ENGLISH_CONFIGURATION, hibernateContext), (NodeBuilder) cb), -// cb.function("to_tsvector", String.class, cb.literal("english"), root.get("shortDescription")), cb.literal("C") ); Expression fullDescriptionVec = cb.function("setweight", String.class, new TSVectorFunction(root.get("fullDescription"), new RegconfigTypeCastOperatorFunction((NodeBuilder) cb, ENGLISH_CONFIGURATION, hibernateContext), (NodeBuilder) cb), -// cb.function("to_tsvector", String.class, cb.literal("english"), root.get("fullDescription")), cb.literal("D") ); // Concatenate tsvectors (|| operator) - Expression fullVector = cb.function("tsvector_concat", String.class, - shortNameVec, fullNameVec, shortDescriptionVec, fullDescriptionVec - ); + SqmExpression fullVector = (SqmExpression) cb.concat(cb.concat(shortNameVec, fullNameVec), cb.concat(shortDescriptionVec, fullDescriptionVec)); // Build tsquery - Expression queryExpr = cb.function( - "plainto_tsquery", String.class, - cb.literal("english"), - cb.literal(phrase) - ); + Expression queryExpr = new WebsearchToTSQueryFunction((NodeBuilder) cb, ENGLISH_CONFIGURATION, phrase); - // WHERE clause using @@ operator (registered as ts_match) - Predicate matches = cb.isTrue( - cb.function("ts_match", Boolean.class, fullVector, queryExpr) - ); + // WHERE clause using @@ operator + TextOperatorFunction matches = new TextOperatorFunction((NodeBuilder) cb, fullVector, new WebsearchToTSQueryFunction((NodeBuilder) cb, new RegconfigTypeCastOperatorFunction((NodeBuilder) cb, ENGLISH_CONFIGURATION, hibernateContext), phrase), hibernateContext); cq.where(matches); From 4e829d567766ddb3364080ded940256aff13355c Mon Sep 17 00:00:00 2001 From: starnowski <33316705+starnowski@users.noreply.github.com> Date: Sat, 18 Oct 2025 00:03:17 +0200 Subject: [PATCH 08/23] #158 - Change argument type passed to text operator method [skip ci] --- .../operators/TextOperatorFunction.java | 49 ++++++++++--------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/operators/TextOperatorFunction.java b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/operators/TextOperatorFunction.java index 7182c0f6..b74424d6 100644 --- a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/operators/TextOperatorFunction.java +++ b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/operators/TextOperatorFunction.java @@ -1,23 +1,23 @@ /** - * 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) + *

+ * 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 */ package com.github.starnowski.posjsonhelper.text.hibernate6.operators; @@ -44,16 +44,16 @@ public class TextOperatorFunction extends SelfRenderingSqmFunction implements Serializable { private final HibernateContext context; - private final TSVectorFunction tsVectorFunction; + private final SqmExpression tsVectorFunction; private final SqmExpression argument; /** - * @param nodeBuilder component of type {@link NodeBuilder} + * @param nodeBuilder component of type {@link NodeBuilder} * @param tsVectorFunction object of type {@link TSVectorFunction} - * @param argument text query expression + * @param argument text query expression * @param hibernateContext context object of type {@link HibernateContext} */ - public TextOperatorFunction(NodeBuilder nodeBuilder, TSVectorFunction tsVectorFunction, SqmExpression argument, HibernateContext hibernateContext) { + public TextOperatorFunction(NodeBuilder nodeBuilder, SqmExpression tsVectorFunction, SqmExpression argument, HibernateContext hibernateContext) { super(nodeBuilder.getQueryEngine().getSqmFunctionRegistry().findFunctionDescriptor(hibernateContext.getTextFunctionOperator()), (FunctionRenderer) nodeBuilder.getQueryEngine().getSqmFunctionRegistry().findFunctionDescriptor(hibernateContext.getTextFunctionOperator()), contactParameters(tsVectorFunction, argument), @@ -67,7 +67,8 @@ public TextOperatorFunction(NodeBuilder nodeBuilder, TSVectorFunction tsVectorFu this.argument = argument; } - private static List> contactParameters(TSVectorFunction tsVectorFunction, SqmExpression argument) { + private static List> contactParameters(SqmExpression tsVectorFunction, + SqmExpression argument) { if (tsVectorFunction == null) { throw new IllegalArgumentException("TSVectorFunction argument can not be null"); } From be88a4ddfd47ff3e9da653ea79f1cbd03704d36f Mon Sep 17 00:00:00 2001 From: starnowski <33316705+starnowski@users.noreply.github.com> Date: Sat, 18 Oct 2025 00:07:14 +0200 Subject: [PATCH 09/23] #158 - Fixed tests case [skip ci] --- .../text/hibernate6/dao/ItemDaoTest.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDaoTest.java b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDaoTest.java index 37e3a799..af6c473b 100644 --- a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDaoTest.java +++ b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDaoTest.java @@ -2,7 +2,6 @@ import com.github.starnowski.posjsonhelper.text.hibernate6.model.Item; import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; @@ -11,12 +10,12 @@ import org.springframework.test.context.jdbc.SqlConfig; import java.util.List; -import java.util.stream.Collectors; import java.util.stream.Stream; -import static com.github.starnowski.posjsonhelper.text.hibernate6.Application.*; +import static com.github.starnowski.posjsonhelper.text.hibernate6.Application.CLEAR_DATABASE_SCRIPT_PATH; +import static com.github.starnowski.posjsonhelper.text.hibernate6.Application.ITEMS_SCRIPT_PATH; import static java.util.Arrays.asList; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.springframework.test.context.jdbc.Sql.ExecutionPhase.BEFORE_TEST_METHOD; import static org.springframework.test.context.jdbc.SqlConfig.TransactionMode.ISOLATED; @@ -28,7 +27,8 @@ class ItemDaoTest extends AbstractItTest { private static Stream provideShouldFindCorrectItemWithOrderBasedOnPhrase() { return Stream.of( - Arguments.of("wing", asList(1L, 2L)) + Arguments.of("wing", true, asList(1L, 2L)), + Arguments.of("wing", false, asList(2L, 1L)) ); } @@ -38,9 +38,9 @@ private static Stream provideShouldFindCorrectItemWithOrderBasedOnPhr @DisplayName("should find correct item with order based on phrase") @ParameterizedTest @MethodSource("provideShouldFindCorrectItemWithOrderBasedOnPhrase") - public void shouldFindCorrectItemWithOrderBasedOnPhrase(String phrase, List expectedIds) { + public void shouldFindCorrectItemWithOrderBasedOnPhrase(String phrase, boolean ascSort, List expectedIds) { // WHEN - List items = itemDao.findItemsByQuery(phrase); + List items = itemDao.findItemsByQuery(phrase, ascSort); // THEN assertEquals(expectedIds, items.stream().map(Item::getId).toList()); From 7d2f10cb467bb8c2f169941c0cde50b03fb5e7a6 Mon Sep 17 00:00:00 2001 From: starnowski <33316705+starnowski@users.noreply.github.com> Date: Sat, 18 Oct 2025 00:07:37 +0200 Subject: [PATCH 10/23] #158 - Fixed test object --- .../posjsonhelper/text/hibernate6/dao/ItemDao.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java index ab8583aa..95b850c8 100644 --- a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java +++ b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java @@ -7,7 +7,10 @@ import com.github.starnowski.posjsonhelper.text.hibernate6.operators.RegconfigTypeCastOperatorFunction; import com.github.starnowski.posjsonhelper.text.hibernate6.operators.TextOperatorFunction; import jakarta.persistence.EntityManager; -import jakarta.persistence.criteria.*; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Root; import org.hibernate.query.sqm.NodeBuilder; import org.hibernate.query.sqm.tree.expression.SqmExpression; import org.springframework.beans.factory.annotation.Autowired; @@ -26,7 +29,7 @@ public class ItemDao { private HibernateContext hibernateContext; - public List findItemsByQuery(String phrase) { + public List findItemsByQuery(String phrase, boolean ascSort) { CriteriaBuilder cb = entityManager.getCriteriaBuilder(); CriteriaQuery cq = cb.createQuery(Item.class); Root root = cq.from(Item.class); @@ -70,7 +73,7 @@ public List findItemsByQuery(String phrase) { queryExpr ); - cq.orderBy(cb.desc(rankExpr)); + cq.orderBy(ascSort ? cb.asc(rankExpr) : cb.desc(rankExpr)); return entityManager.createQuery(cq).getResultList(); } From a362fbad117ac1fd3a4eae48d3c5938956b3cbaf Mon Sep 17 00:00:00 2001 From: starnowski <33316705+starnowski@users.noreply.github.com> Date: Sun, 19 Oct 2025 01:27:08 +0200 Subject: [PATCH 11/23] #158 - Code refactor plus added tests check --- .../posjsonhelper/text/hibernate6/dao/ItemDao.java | 2 +- .../posjsonhelper/text/hibernate6/dao/ItemDaoTest.java | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java index 95b850c8..870c8f51 100644 --- a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java +++ b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java @@ -29,7 +29,7 @@ public class ItemDao { private HibernateContext hibernateContext; - public List findItemsByQuery(String phrase, boolean ascSort) { + public List findItemsByWebSearchToTSQuerySortedByTsRank(String phrase, boolean ascSort) { CriteriaBuilder cb = entityManager.getCriteriaBuilder(); CriteriaQuery cq = cb.createQuery(Item.class); Root root = cq.from(Item.class); diff --git a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDaoTest.java b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDaoTest.java index af6c473b..d9a73c0e 100644 --- a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDaoTest.java +++ b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDaoTest.java @@ -16,6 +16,7 @@ import static com.github.starnowski.posjsonhelper.text.hibernate6.Application.ITEMS_SCRIPT_PATH; import static java.util.Arrays.asList; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import static org.springframework.test.context.jdbc.Sql.ExecutionPhase.BEFORE_TEST_METHOD; import static org.springframework.test.context.jdbc.SqlConfig.TransactionMode.ISOLATED; @@ -39,8 +40,10 @@ private static Stream provideShouldFindCorrectItemWithOrderBasedOnPhr @ParameterizedTest @MethodSource("provideShouldFindCorrectItemWithOrderBasedOnPhrase") public void shouldFindCorrectItemWithOrderBasedOnPhrase(String phrase, boolean ascSort, List expectedIds) { + assumeTrue(postgresVersion.getMajor() >= 11, "Test ignored because the 'websearch_to_tsquery' function was added in version 10 of Postgres"); + // WHEN - List items = itemDao.findItemsByQuery(phrase, ascSort); + List items = itemDao.findItemsByWebSearchToTSQuerySortedByTsRank(phrase, ascSort); // THEN assertEquals(expectedIds, items.stream().map(Item::getId).toList()); From 11757f98208ac294d121078b47288a4266442500 Mon Sep 17 00:00:00 2001 From: starnowski <33316705+starnowski@users.noreply.github.com> Date: Sun, 19 Oct 2025 01:50:32 +0200 Subject: [PATCH 12/23] #158 - Added part of query [skip ci] --- .../text/hibernate6/dao/ItemDao.java | 27 +++++++++++++++++++ .../text/hibernate6/dao/ItemDaoTest.java | 16 +++++++++++ 2 files changed, 43 insertions(+) diff --git a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java index 870c8f51..4e4ceda2 100644 --- a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java +++ b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java @@ -4,9 +4,11 @@ import com.github.starnowski.posjsonhelper.text.hibernate6.functions.TSVectorFunction; import com.github.starnowski.posjsonhelper.text.hibernate6.functions.WebsearchToTSQueryFunction; import com.github.starnowski.posjsonhelper.text.hibernate6.model.Item; +import com.github.starnowski.posjsonhelper.text.hibernate6.model.Tweet; import com.github.starnowski.posjsonhelper.text.hibernate6.operators.RegconfigTypeCastOperatorFunction; import com.github.starnowski.posjsonhelper.text.hibernate6.operators.TextOperatorFunction; import jakarta.persistence.EntityManager; +import jakarta.persistence.TypedQuery; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.CriteriaQuery; import jakarta.persistence.criteria.Expression; @@ -77,4 +79,29 @@ public List findItemsByWebSearchToTSQuerySortedByTsRank(String phrase, boo return entityManager.createQuery(cq).getResultList(); } + + public List findItemsByWebSearchToTSQuerySortedByTsRankInHQL(String phrase, boolean ascSort) { + StringBuilder statement = new StringBuilder(); + statement.append("from Item as item where "); + statement.append("text_operator_function("); // text_operator_function - start + statement.append("concat("); // main concat - start + statement.append("concat("); // first concat - start + statement.append("function('setweight', to_tsvector('%1$s', item.shortName), literal('A'))"); + statement.append(","); + statement.append("function('setweight', to_tsvector('%1$s', item.fullName), literal('B'))"); + statement.append(")"); // first concat - end + statement.append(","); // main concat - separator + statement.append("concat("); // second concat - start + statement.append("function('setweight', to_tsvector('%1$s', item.shortDescription), literal('C'))"); + statement.append(","); + statement.append("function('setweight', to_tsvector('%1$s', item.fullDescription), literal('D'))"); + statement.append(")"); // first second - end + statement.append(")"); // main concat - end + statement.append(","); // text_operator_function - separator + statement.append(")"); // text_operator_function - end + + TypedQuery query = entityManager.createQuery(statement.toString().formatted(ENGLISH_CONFIGURATION), Item.class); + query.setParameter("phrase", phrase); + return query.getResultList(); + } } diff --git a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDaoTest.java b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDaoTest.java index d9a73c0e..57608447 100644 --- a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDaoTest.java +++ b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDaoTest.java @@ -48,4 +48,20 @@ public void shouldFindCorrectItemWithOrderBasedOnPhrase(String phrase, boolean a // THEN assertEquals(expectedIds, items.stream().map(Item::getId).toList()); } + + @Sql(value = {CLEAR_DATABASE_SCRIPT_PATH, ITEMS_SCRIPT_PATH}, + config = @SqlConfig(transactionMode = ISOLATED), + executionPhase = BEFORE_TEST_METHOD) + @DisplayName("should find correct item with order based on phrase") + @ParameterizedTest + @MethodSource("provideShouldFindCorrectItemWithOrderBasedOnPhrase") + public void shouldFindCorrectItemWithOrderBasedOnPhraseInHQL(String phrase, boolean ascSort, List expectedIds) { + assumeTrue(postgresVersion.getMajor() >= 11, "Test ignored because the 'websearch_to_tsquery' function was added in version 10 of Postgres"); + + // WHEN + List items = itemDao.findItemsByWebSearchToTSQuerySortedByTsRankInHQL(phrase, ascSort); + + // THEN + assertEquals(expectedIds, items.stream().map(Item::getId).toList()); + } } \ No newline at end of file From 9a01f65cb0c6616b25ed342d78fc674298bf1d4a Mon Sep 17 00:00:00 2001 From: starnowski <33316705+starnowski@users.noreply.github.com> Date: Sun, 19 Oct 2025 02:14:07 +0200 Subject: [PATCH 13/23] #158 - Added partial implementation [skip ci] --- .../text/hibernate6/dao/ItemDao.java | 33 ++++++++++++++++--- .../TextOperatorFunctionDescriptor.java | 4 +-- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java index 4e4ceda2..d6b387c8 100644 --- a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java +++ b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java @@ -86,19 +86,44 @@ public List findItemsByWebSearchToTSQuerySortedByTsRankInHQL(String phrase statement.append("text_operator_function("); // text_operator_function - start statement.append("concat("); // main concat - start statement.append("concat("); // first concat - start - statement.append("function('setweight', to_tsvector('%1$s', item.shortName), literal('A'))"); + statement.append("function('setweight', to_tsvector('%1$s', item.shortName), 'A')"); statement.append(","); - statement.append("function('setweight', to_tsvector('%1$s', item.fullName), literal('B'))"); + statement.append("function('setweight', to_tsvector('%1$s', item.fullName), 'B')"); statement.append(")"); // first concat - end statement.append(","); // main concat - separator statement.append("concat("); // second concat - start - statement.append("function('setweight', to_tsvector('%1$s', item.shortDescription), literal('C'))"); + statement.append("function('setweight', to_tsvector('%1$s', item.shortDescription), 'C')"); statement.append(","); - statement.append("function('setweight', to_tsvector('%1$s', item.fullDescription), literal('D'))"); + statement.append("function('setweight', to_tsvector('%1$s', item.fullDescription), 'D')"); statement.append(")"); // first second - end statement.append(")"); // main concat - end statement.append(","); // text_operator_function - separator + + statement.append("websearch_to_tsquery(cast_operator_function('%1$s','regconfig'), :phrase)"); // websearch_to_tsquery operator + statement.append(")"); // text_operator_function - end + statement.append(" order by "); // order - start + + + statement.append("function('ts_rank', "); // ts_rank function - start + statement.append("concat("); // main concat - start + statement.append("concat("); // first concat - start + statement.append("function('setweight', to_tsvector('%1$s', item.shortName), 'A')"); + statement.append(","); + statement.append("function('setweight', to_tsvector('%1$s', item.fullName), 'B')"); + statement.append(")"); // first concat - end + statement.append(","); // main concat - separator + statement.append("concat("); // second concat - start + statement.append("function('setweight', to_tsvector('%1$s', item.shortDescription), 'C')"); + statement.append(","); + statement.append("function('setweight', to_tsvector('%1$s', item.fullDescription), 'D')"); + statement.append(")"); // first second - end + statement.append(")"); // main concat - end + statement.append(","); // ts_rank function - separator + + statement.append("websearch_to_tsquery(cast_operator_function('%1$s','regconfig'), :phrase)"); // websearch_to_tsquery operator + + statement.append(")"); // ts_rank function - end TypedQuery query = entityManager.createQuery(statement.toString().formatted(ENGLISH_CONFIGURATION), Item.class); query.setParameter("phrase", phrase); diff --git a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/descriptor/TextOperatorFunctionDescriptor.java b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/descriptor/TextOperatorFunctionDescriptor.java index 9bd73f9c..c6e7f7f1 100644 --- a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/descriptor/TextOperatorFunctionDescriptor.java +++ b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/descriptor/TextOperatorFunctionDescriptor.java @@ -40,7 +40,7 @@ /** * Function descriptor for text postgres operator. - * Generally it renders passed arguments that one is TSVectorFunction object type and second is expression that represents text query. + * Generally it renders passed arguments that one is SqmExpression object type and second is expression that represents text query. * For example: * SQL *

{@code
@@ -73,6 +73,6 @@ protected  SelfRenderingSqmFunction generateSqmFunctionExpression(List) arguments.get(i));
         }
-        return (SelfRenderingSqmFunction) new TextOperatorFunction(queryEngine.getCriteriaBuilder(), (TSVectorFunction) args.get(0), args.get(1), hibernateContext);
+        return (SelfRenderingSqmFunction) new TextOperatorFunction(queryEngine.getCriteriaBuilder(),  args.get(0), args.get(1), hibernateContext);
     }
 }
\ No newline at end of file

From eba9205ef39fda93a8837ec88726f8f978b74a6e Mon Sep 17 00:00:00 2001
From: starnowski <33316705+starnowski@users.noreply.github.com>
Date: Sun, 19 Oct 2025 02:22:25 +0200
Subject: [PATCH 14/23] #158 - Added tests case

---
 .../text/hibernate6/dao/ItemDao.java          | 91 +++++++++----------
 1 file changed, 45 insertions(+), 46 deletions(-)

diff --git a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java
index d6b387c8..68402ba3 100644
--- a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java
+++ b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java
@@ -4,7 +4,6 @@
 import com.github.starnowski.posjsonhelper.text.hibernate6.functions.TSVectorFunction;
 import com.github.starnowski.posjsonhelper.text.hibernate6.functions.WebsearchToTSQueryFunction;
 import com.github.starnowski.posjsonhelper.text.hibernate6.model.Item;
-import com.github.starnowski.posjsonhelper.text.hibernate6.model.Tweet;
 import com.github.starnowski.posjsonhelper.text.hibernate6.operators.RegconfigTypeCastOperatorFunction;
 import com.github.starnowski.posjsonhelper.text.hibernate6.operators.TextOperatorFunction;
 import jakarta.persistence.EntityManager;
@@ -81,51 +80,51 @@ public List findItemsByWebSearchToTSQuerySortedByTsRank(String phrase, boo
     }
 
     public List findItemsByWebSearchToTSQuerySortedByTsRankInHQL(String phrase, boolean ascSort) {
-        StringBuilder statement = new StringBuilder();
-        statement.append("from Item as item where ");
-        statement.append("text_operator_function("); // text_operator_function - start
-        statement.append("concat("); // main concat - start
-        statement.append("concat("); // first concat - start
-        statement.append("function('setweight', to_tsvector('%1$s', item.shortName), 'A')");
-        statement.append(",");
-        statement.append("function('setweight', to_tsvector('%1$s', item.fullName), 'B')");
-        statement.append(")"); // first concat - end
-        statement.append(","); // main concat - separator
-        statement.append("concat("); // second concat - start
-        statement.append("function('setweight', to_tsvector('%1$s', item.shortDescription), 'C')");
-        statement.append(",");
-        statement.append("function('setweight', to_tsvector('%1$s', item.fullDescription), 'D')");
-        statement.append(")"); // first second - end
-        statement.append(")"); // main concat - end
-        statement.append(","); // text_operator_function - separator
-
-        statement.append("websearch_to_tsquery(cast_operator_function('%1$s','regconfig'), :phrase)"); // websearch_to_tsquery operator
-
-        statement.append(")"); // text_operator_function - end
-        statement.append(" order by "); // order - start
-
-
-        statement.append("function('ts_rank', "); // ts_rank function - start
-        statement.append("concat("); // main concat - start
-        statement.append("concat("); // first concat - start
-        statement.append("function('setweight', to_tsvector('%1$s', item.shortName), 'A')");
-        statement.append(",");
-        statement.append("function('setweight', to_tsvector('%1$s', item.fullName), 'B')");
-        statement.append(")"); // first concat - end
-        statement.append(","); // main concat - separator
-        statement.append("concat("); // second concat - start
-        statement.append("function('setweight', to_tsvector('%1$s', item.shortDescription), 'C')");
-        statement.append(",");
-        statement.append("function('setweight', to_tsvector('%1$s', item.fullDescription), 'D')");
-        statement.append(")"); // first second - end
-        statement.append(")"); // main concat - end
-        statement.append(","); // ts_rank function - separator
-
-        statement.append("websearch_to_tsquery(cast_operator_function('%1$s','regconfig'), :phrase)"); // websearch_to_tsquery operator
-
-        statement.append(")"); // ts_rank function - end
-
-        TypedQuery query = entityManager.createQuery(statement.toString().formatted(ENGLISH_CONFIGURATION), Item.class);
+        String statement = "from Item as item where " +
+                "text_operator_function(" + // text_operator_function - start
+                "concat(" + // main concat - start
+                "concat(" + // first concat - start
+                "function('setweight', to_tsvector('%1$s', item.shortName), 'A')" +
+                "," +
+                "function('setweight', to_tsvector('%1$s', item.fullName), 'B')" +
+                ")" + // first concat - end
+                "," + // main concat - separator
+                "concat(" + // second concat - start
+                "function('setweight', to_tsvector('%1$s', item.shortDescription), 'C')" +
+                "," +
+                "function('setweight', to_tsvector('%1$s', item.fullDescription), 'D')" +
+                ")" + // first second - end
+                ")" + // main concat - end
+                "," + // text_operator_function - separator
+
+                "websearch_to_tsquery(cast_operator_function('%1$s','regconfig'), :phrase)" + // websearch_to_tsquery operator
+
+                ")" + // text_operator_function - end
+                " order by " + // order - start
+
+
+                "function('ts_rank', " + // ts_rank function - start
+                "concat(" + // main concat - start
+                "concat(" + // first concat - start
+                "function('setweight', to_tsvector('%1$s', item.shortName), 'A')" +
+                "," +
+                "function('setweight', to_tsvector('%1$s', item.fullName), 'B')" +
+                ")" + // first concat - end
+                "," + // main concat - separator
+                "concat(" + // second concat - start
+                "function('setweight', to_tsvector('%1$s', item.shortDescription), 'C')" +
+                "," +
+                "function('setweight', to_tsvector('%1$s', item.fullDescription), 'D')" +
+                ")" + // first second - end
+                ")" + // main concat - end
+                "," + // ts_rank function - separator
+
+                "websearch_to_tsquery(cast_operator_function('%1$s','regconfig'), :phrase)" + // websearch_to_tsquery operator
+
+                ")" + // ts_rank function - end
+                (ascSort ? " asc" : "desc");
+
+        TypedQuery query = entityManager.createQuery(statement.formatted(ENGLISH_CONFIGURATION), Item.class);
         query.setParameter("phrase", phrase);
         return query.getResultList();
     }

From 4cda5e25161c15b9c30c3e5ce8f3234cd8e09e90 Mon Sep 17 00:00:00 2001
From: starnowski <33316705+starnowski@users.noreply.github.com>
Date: Sun, 19 Oct 2025 11:33:58 +0200
Subject: [PATCH 15/23] #158 - Added in CHANGELOG.md

---
 CHANGELOG.md   | 5 +++++
 text/README.md | 2 ++
 2 files changed, 7 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 521df608..047e1815 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -26,6 +26,11 @@ https://www.markdownguide.org/basic-syntax/
 
 ## [Unreleased]
 
+## [0.4.4] - 2025-10-19
+TODO
+- Changed constructor com.github.starnowski.posjsonhelper.text.hibernate6.operators.TextOperatorFunction#TextOperatorFunction(org.hibernate.query.sqm.NodeBuilder, com.github.starnowski.posjsonhelper.text.hibernate6.functions.TSVectorFunction, org.hibernate.query.sqm.tree.expression.SqmExpression, com.github.starnowski.posjsonhelper.core.HibernateContext) to com.github.starnowski.posjsonhelper.text.hibernate6.operators.TextOperatorFunction#TextOperatorFunction(org.hibernate.query.sqm.NodeBuilder, org.hibernate.query.sqm.tree.expression.SqmExpression, org.hibernate.query.sqm.tree.expression.SqmExpression, com.github.starnowski.posjsonhelper.core.HibernateContext) [158](https://github.com/starnowski/posjsonhelper/issues/158)
+
+
 ## [0.4.3] - 2025-06-29
 
 ### Added
diff --git a/text/README.md b/text/README.md
index 3e95f8e8..b6ec0e7d 100644
--- a/text/README.md
+++ b/text/README.md
@@ -25,6 +25,8 @@ The library is written in a java programming language.
 The project for this moment supports Hibernate in version 6.
 The required version of java is at least version 11.
 
+# How to start using posjsonhelper
+
 ### Setting maven dependency
 The project is available in the central maven repository.
 You can use it just by adding it as a dependency in the project descriptor file (pom.xml).

From 599248d942a0615b0374aa5a965c20a215f3f5f5 Mon Sep 17 00:00:00 2001
From: starnowski <33316705+starnowski@users.noreply.github.com>
Date: Sun, 19 Oct 2025 11:43:10 +0200
Subject: [PATCH 16/23] #158 - Added tests case for the ts_rank_cd function

---
 .../text/hibernate6/dao/ItemDao.java          | 99 +++++++++++++++++++
 .../text/hibernate6/dao/ItemDaoTest.java      | 36 ++++++-
 2 files changed, 133 insertions(+), 2 deletions(-)

diff --git a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java
index 68402ba3..358512d0 100644
--- a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java
+++ b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDao.java
@@ -128,4 +128,103 @@ public List findItemsByWebSearchToTSQuerySortedByTsRankInHQL(String phrase
         query.setParameter("phrase", phrase);
         return query.getResultList();
     }
+
+    public List findItemsByWebSearchToTSQuerySortedByTsRankCd(String phrase, boolean ascSort) {
+        CriteriaBuilder cb = entityManager.getCriteriaBuilder();
+        CriteriaQuery cq = cb.createQuery(Item.class);
+        Root root = cq.from(Item.class);
+
+        // Build weighted tsvector using posjsonhelper functions
+        Expression shortNameVec = cb.function("setweight", String.class,
+                new TSVectorFunction(root.get("shortName"), new RegconfigTypeCastOperatorFunction((NodeBuilder) cb, ENGLISH_CONFIGURATION, hibernateContext), (NodeBuilder) cb),
+                cb.literal("A")
+        );
+
+        Expression fullNameVec = cb.function("setweight", String.class,
+                new TSVectorFunction(root.get("fullName"), new RegconfigTypeCastOperatorFunction((NodeBuilder) cb, ENGLISH_CONFIGURATION, hibernateContext), (NodeBuilder) cb),
+                cb.literal("B")
+        );
+
+        Expression shortDescriptionVec = cb.function("setweight", String.class,
+                new TSVectorFunction(root.get("shortDescription"), new RegconfigTypeCastOperatorFunction((NodeBuilder) cb, ENGLISH_CONFIGURATION, hibernateContext), (NodeBuilder) cb),
+                cb.literal("C")
+        );
+
+        Expression fullDescriptionVec = cb.function("setweight", String.class,
+                new TSVectorFunction(root.get("fullDescription"), new RegconfigTypeCastOperatorFunction((NodeBuilder) cb, ENGLISH_CONFIGURATION, hibernateContext), (NodeBuilder) cb),
+                cb.literal("D")
+        );
+
+        // Concatenate tsvectors (|| operator)
+        SqmExpression fullVector = (SqmExpression) cb.concat(cb.concat(shortNameVec, fullNameVec), cb.concat(shortDescriptionVec, fullDescriptionVec));
+
+        // Build tsquery
+        Expression queryExpr = new WebsearchToTSQueryFunction((NodeBuilder) cb, ENGLISH_CONFIGURATION, phrase);
+
+        // WHERE clause using @@ operator
+        TextOperatorFunction matches = new TextOperatorFunction((NodeBuilder) cb, fullVector, new WebsearchToTSQueryFunction((NodeBuilder) cb, new RegconfigTypeCastOperatorFunction((NodeBuilder) cb, ENGLISH_CONFIGURATION, hibernateContext), phrase), hibernateContext);
+
+        cq.where(matches);
+
+        // Ranking
+        Expression rankExpr = cb.function(
+                "ts_rank_cd", Double.class,
+                fullVector,
+                queryExpr
+        );
+
+        cq.orderBy(ascSort ? cb.asc(rankExpr) : cb.desc(rankExpr));
+
+        return entityManager.createQuery(cq).getResultList();
+    }
+
+    public List findItemsByWebSearchToTSQuerySortedByTsRankCdInHQL(String phrase, boolean ascSort) {
+        String statement = "from Item as item where " +
+                "text_operator_function(" + // text_operator_function - start
+                "concat(" + // main concat - start
+                "concat(" + // first concat - start
+                "function('setweight', to_tsvector('%1$s', item.shortName), 'A')" +
+                "," +
+                "function('setweight', to_tsvector('%1$s', item.fullName), 'B')" +
+                ")" + // first concat - end
+                "," + // main concat - separator
+                "concat(" + // second concat - start
+                "function('setweight', to_tsvector('%1$s', item.shortDescription), 'C')" +
+                "," +
+                "function('setweight', to_tsvector('%1$s', item.fullDescription), 'D')" +
+                ")" + // first second - end
+                ")" + // main concat - end
+                "," + // text_operator_function - separator
+
+                "websearch_to_tsquery(cast_operator_function('%1$s','regconfig'), :phrase)" + // websearch_to_tsquery operator
+
+                ")" + // text_operator_function - end
+                " order by " + // order - start
+
+
+                "function('ts_rank_cd', " + // ts_rank function - start
+                "concat(" + // main concat - start
+                "concat(" + // first concat - start
+                "function('setweight', to_tsvector('%1$s', item.shortName), 'A')" +
+                "," +
+                "function('setweight', to_tsvector('%1$s', item.fullName), 'B')" +
+                ")" + // first concat - end
+                "," + // main concat - separator
+                "concat(" + // second concat - start
+                "function('setweight', to_tsvector('%1$s', item.shortDescription), 'C')" +
+                "," +
+                "function('setweight', to_tsvector('%1$s', item.fullDescription), 'D')" +
+                ")" + // first second - end
+                ")" + // main concat - end
+                "," + // ts_rank function - separator
+
+                "websearch_to_tsquery(cast_operator_function('%1$s','regconfig'), :phrase)" + // websearch_to_tsquery operator
+
+                ")" + // ts_rank function - end
+                (ascSort ? " asc" : "desc");
+
+        TypedQuery query = entityManager.createQuery(statement.formatted(ENGLISH_CONFIGURATION), Item.class);
+        query.setParameter("phrase", phrase);
+        return query.getResultList();
+    }
 }
diff --git a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDaoTest.java b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDaoTest.java
index 57608447..8b97d133 100644
--- a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDaoTest.java
+++ b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDaoTest.java
@@ -39,7 +39,7 @@ private static Stream provideShouldFindCorrectItemWithOrderBasedOnPhr
     @DisplayName("should find correct item with order based on phrase")
     @ParameterizedTest
     @MethodSource("provideShouldFindCorrectItemWithOrderBasedOnPhrase")
-    public void shouldFindCorrectItemWithOrderBasedOnPhrase(String phrase, boolean ascSort, List expectedIds) {
+    public void shouldFindCorrectItemWithOrderBasedOnPhraseRankedByTsRank(String phrase, boolean ascSort, List expectedIds) {
         assumeTrue(postgresVersion.getMajor() >= 11, "Test ignored because the 'websearch_to_tsquery' function was added in version 10 of Postgres");
 
         // WHEN
@@ -55,7 +55,7 @@ public void shouldFindCorrectItemWithOrderBasedOnPhrase(String phrase, boolean a
     @DisplayName("should find correct item with order based on phrase")
     @ParameterizedTest
     @MethodSource("provideShouldFindCorrectItemWithOrderBasedOnPhrase")
-    public void shouldFindCorrectItemWithOrderBasedOnPhraseInHQL(String phrase, boolean ascSort, List expectedIds) {
+    public void shouldFindCorrectItemWithOrderBasedOnPhraseRankedByTsRankInHQL(String phrase, boolean ascSort, List expectedIds) {
         assumeTrue(postgresVersion.getMajor() >= 11, "Test ignored because the 'websearch_to_tsquery' function was added in version 10 of Postgres");
 
         // WHEN
@@ -64,4 +64,36 @@ public void shouldFindCorrectItemWithOrderBasedOnPhraseInHQL(String phrase, bool
         // THEN
         assertEquals(expectedIds, items.stream().map(Item::getId).toList());
     }
+
+    @Sql(value = {CLEAR_DATABASE_SCRIPT_PATH, ITEMS_SCRIPT_PATH},
+            config = @SqlConfig(transactionMode = ISOLATED),
+            executionPhase = BEFORE_TEST_METHOD)
+    @DisplayName("should find correct item with order based on phrase")
+    @ParameterizedTest
+    @MethodSource("provideShouldFindCorrectItemWithOrderBasedOnPhrase")
+    public void shouldFindCorrectItemWithOrderBasedOnPhraseRankedByTsRankCd(String phrase, boolean ascSort, List expectedIds) {
+        assumeTrue(postgresVersion.getMajor() >= 11, "Test ignored because the 'websearch_to_tsquery' function was added in version 10 of Postgres");
+
+        // WHEN
+        List items = itemDao.findItemsByWebSearchToTSQuerySortedByTsRankCd(phrase, ascSort);
+
+        // THEN
+        assertEquals(expectedIds, items.stream().map(Item::getId).toList());
+    }
+
+    @Sql(value = {CLEAR_DATABASE_SCRIPT_PATH, ITEMS_SCRIPT_PATH},
+            config = @SqlConfig(transactionMode = ISOLATED),
+            executionPhase = BEFORE_TEST_METHOD)
+    @DisplayName("should find correct item with order based on phrase")
+    @ParameterizedTest
+    @MethodSource("provideShouldFindCorrectItemWithOrderBasedOnPhrase")
+    public void shouldFindCorrectItemWithOrderBasedOnPhraseRankedByTsRankCdInHQL(String phrase, boolean ascSort, List expectedIds) {
+        assumeTrue(postgresVersion.getMajor() >= 11, "Test ignored because the 'websearch_to_tsquery' function was added in version 10 of Postgres");
+
+        // WHEN
+        List items = itemDao.findItemsByWebSearchToTSQuerySortedByTsRankCdInHQL(phrase, ascSort);
+
+        // THEN
+        assertEquals(expectedIds, items.stream().map(Item::getId).toList());
+    }
 }
\ No newline at end of file

From 9e45f944f77e24db74622184b0a108b8d9edb2a4 Mon Sep 17 00:00:00 2001
From: starnowski <33316705+starnowski@users.noreply.github.com>
Date: Sun, 19 Oct 2025 12:42:31 +0200
Subject: [PATCH 17/23] #158 - Added TODO comments

---
 .../text/hibernate6/dao/ItemDaoTest.java      | 26 +++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDaoTest.java b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDaoTest.java
index 8b97d133..f15aec52 100644
--- a/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDaoTest.java
+++ b/text/hibernate6-text-tests/src/test/java/com/github/starnowski/posjsonhelper/text/hibernate6/dao/ItemDaoTest.java
@@ -33,6 +33,15 @@ private static Stream provideShouldFindCorrectItemWithOrderBasedOnPhr
         );
     }
 
+    //TODO
+//    private static Stream provideShouldFindCorrectItemWithOrderBasedOnPhraseWithWeights() {
+//        return Stream.of(
+//                Arguments.of("wing", true, asList(1L, 2L), new float[]{1.0f, 0.8f, 0.4f, 0.2f}),
+//                Arguments.of("wing", false, asList(2L, 1L), new float[]{1.0f, 0.8f, 0.4f, 0.2f})
+//        );
+//    }
+
+
     @Sql(value = {CLEAR_DATABASE_SCRIPT_PATH, ITEMS_SCRIPT_PATH},
             config = @SqlConfig(transactionMode = ISOLATED),
             executionPhase = BEFORE_TEST_METHOD)
@@ -96,4 +105,21 @@ public void shouldFindCorrectItemWithOrderBasedOnPhraseRankedByTsRankCdInHQL(Str
         // THEN
         assertEquals(expectedIds, items.stream().map(Item::getId).toList());
     }
+
+    // TODO
+//    @Sql(value = {CLEAR_DATABASE_SCRIPT_PATH, ITEMS_SCRIPT_PATH},
+//            config = @SqlConfig(transactionMode = ISOLATED),
+//            executionPhase = BEFORE_TEST_METHOD)
+//    @DisplayName("should find correct item with order based on phrase and custom weights")
+//    @ParameterizedTest
+//    @MethodSource("provideShouldFindCorrectItemWithOrderBasedOnPhraseWithWeights")
+//    public void shouldFindCorrectItemWithOrderBasedOnPhraseRankedByTsRankWithCustomWeights(String phrase, boolean ascSort, List expectedIds, float[] weights) {
+//        assumeTrue(postgresVersion.getMajor() >= 11, "Test ignored because the 'websearch_to_tsquery' function was added in version 10 of Postgres");
+//
+//        // WHEN
+//        List items = itemDao.findItemsByWebSearchToTSQuerySortedByTsRankWithCustomW(phrase, ascSort, weights);
+//
+//        // THEN
+//        assertEquals(expectedIds, items.stream().map(Item::getId).toList());
+//    }
 }
\ No newline at end of file

From b49c85e639f2e536c774ff3178c34245ad5f57cc Mon Sep 17 00:00:00 2001
From: starnowski <33316705+starnowski@users.noreply.github.com>
Date: Sun, 19 Oct 2025 12:56:22 +0200
Subject: [PATCH 18/23] #158 - Added note about ranking

---
 text/README.md | 230 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 230 insertions(+)

diff --git a/text/README.md b/text/README.md
index b6ec0e7d..ca6a542c 100644
--- a/text/README.md
+++ b/text/README.md
@@ -15,6 +15,7 @@
   * [Function 'phraseto_tsquery'](#function-phraseto_tsquery)
   * [Function 'websearch_to_tsquery'](#function-websearch_to_tsquery)
   * [Function 'to_tsquery'](#function-to_tsquery)
+* [Text ranking with ts_rank and ts_rank_cd](#text-ranking-with-ts_rank-and-ts_rank_cd)
 * [Properties](#properties)
 * [Reporting issues](#reporting-issues)
 * [Project contribution](#project-contribution)
@@ -329,6 +330,235 @@ And the same example but with HQL:
     }
 ```
 
+### Text ranking with ts_rank and ts_rank_cd
+
+PostgreSQL provides ranking functions that allow ordering search results based on the relevance of a match between a document and a search query.  
+Two most commonly used ranking functions are [`ts_rank`](https://www.postgresql.org/docs/current/textsearch-controls.html) and [`ts_rank_cd`](https://www.postgresql.org/docs/current/textsearch-controls.html).
+
+* **`ts_rank`** — calculates a rank based on term frequency and inverse document frequency (TF/IDF).
+* **`ts_rank_cd`** — a variant that uses cover density ranking, which tends to favor documents where query terms appear close together.
+
+Currently, **posjsonhelper** does not provide direct wrappers for these ranking functions.  
+However, it is still possible to use them by leveraging the **Hibernate Criteria API** or **HQL**, as shown below.
+
+##### Example: Ranking using `ts_rank`
+
+The following example demonstrates how to calculate and sort results by the `ts_rank` function using Hibernate’s Criteria API:
+
+```java
+public List findItemsByWebSearchToTSQuerySortedByTsRank(String phrase, boolean ascSort) {
+        CriteriaBuilder cb = entityManager.getCriteriaBuilder();
+        CriteriaQuery cq = cb.createQuery(Item.class);
+        Root root = cq.from(Item.class);
+
+        // Build weighted tsvector using posjsonhelper functions
+        Expression shortNameVec = cb.function("setweight", String.class,
+                new TSVectorFunction(root.get("shortName"), new RegconfigTypeCastOperatorFunction((NodeBuilder) cb, ENGLISH_CONFIGURATION, hibernateContext), (NodeBuilder) cb),
+                cb.literal("A")
+        );
+
+        Expression fullNameVec = cb.function("setweight", String.class,
+                new TSVectorFunction(root.get("fullName"), new RegconfigTypeCastOperatorFunction((NodeBuilder) cb, ENGLISH_CONFIGURATION, hibernateContext), (NodeBuilder) cb),
+                cb.literal("B")
+        );
+
+        Expression shortDescriptionVec = cb.function("setweight", String.class,
+                new TSVectorFunction(root.get("shortDescription"), new RegconfigTypeCastOperatorFunction((NodeBuilder) cb, ENGLISH_CONFIGURATION, hibernateContext), (NodeBuilder) cb),
+                cb.literal("C")
+        );
+
+        Expression fullDescriptionVec = cb.function("setweight", String.class,
+                new TSVectorFunction(root.get("fullDescription"), new RegconfigTypeCastOperatorFunction((NodeBuilder) cb, ENGLISH_CONFIGURATION, hibernateContext), (NodeBuilder) cb),
+                cb.literal("D")
+        );
+
+        // Concatenate tsvectors (|| operator)
+        SqmExpression fullVector = (SqmExpression) cb.concat(cb.concat(shortNameVec, fullNameVec), cb.concat(shortDescriptionVec, fullDescriptionVec));
+
+        // Build tsquery
+        Expression queryExpr = new WebsearchToTSQueryFunction((NodeBuilder) cb, ENGLISH_CONFIGURATION, phrase);
+
+        // WHERE clause using @@ operator
+        TextOperatorFunction matches = new TextOperatorFunction((NodeBuilder) cb, fullVector, new WebsearchToTSQueryFunction((NodeBuilder) cb, new RegconfigTypeCastOperatorFunction((NodeBuilder) cb, ENGLISH_CONFIGURATION, hibernateContext), phrase), hibernateContext);
+
+        cq.where(matches);
+
+        // Ranking
+        Expression rankExpr = cb.function(
+                "ts_rank", Double.class,
+                fullVector,
+                queryExpr
+        );
+
+        cq.orderBy(ascSort ? cb.asc(rankExpr) : cb.desc(rankExpr));
+
+        return entityManager.createQuery(cq).getResultList();
+    }
+```
+
+This query produces SQL similar to:
+
+```sql
+select
+        i1_0.id,
+        i1_0.full_description,
+        i1_0.full_name,
+        i1_0.short_description,
+        i1_0.short_name 
+    from
+        item i1_0 
+    where
+        (
+            (
+                setweight(to_tsvector(?::regconfig, i1_0.short_name), 'A')||setweight(
+                    to_tsvector(?::regconfig, i1_0.full_name), 'B'
+                )
+            )||(
+                setweight(to_tsvector(?::regconfig, i1_0.short_description), 'C')||setweight(
+                    to_tsvector(?::regconfig, i1_0.full_description), 'D'
+                )
+            )
+        ) @@ websearch_to_tsquery(?::regconfig, ?) 
+    order by
+        ts_rank(((setweight(to_tsvector(?::regconfig, i1_0.short_name), 'A')||setweight(to_tsvector(?::regconfig, i1_0.full_name), 'B'))||(setweight(to_tsvector(?::regconfig, i1_0.short_description), 'C')||setweight(to_tsvector(?::regconfig, i1_0.full_description), 'D'))), websearch_to_tsquery('english', ?))
+```
+
+Example: Ranking using ts_rank_cd
+
+To use the cover density ranking method, replace the ranking function name with ts_rank_cd:
+
+```java
+public List findItemsByWebSearchToTSQuerySortedByTsRankCd(String phrase, boolean ascSort) {
+        CriteriaBuilder cb = entityManager.getCriteriaBuilder();
+        CriteriaQuery cq = cb.createQuery(Item.class);
+        Root root = cq.from(Item.class);
+
+        // Build weighted tsvector using posjsonhelper functions
+        Expression shortNameVec = cb.function("setweight", String.class,
+                new TSVectorFunction(root.get("shortName"), new RegconfigTypeCastOperatorFunction((NodeBuilder) cb, ENGLISH_CONFIGURATION, hibernateContext), (NodeBuilder) cb),
+                cb.literal("A")
+        );
+
+        Expression fullNameVec = cb.function("setweight", String.class,
+                new TSVectorFunction(root.get("fullName"), new RegconfigTypeCastOperatorFunction((NodeBuilder) cb, ENGLISH_CONFIGURATION, hibernateContext), (NodeBuilder) cb),
+                cb.literal("B")
+        );
+
+        Expression shortDescriptionVec = cb.function("setweight", String.class,
+                new TSVectorFunction(root.get("shortDescription"), new RegconfigTypeCastOperatorFunction((NodeBuilder) cb, ENGLISH_CONFIGURATION, hibernateContext), (NodeBuilder) cb),
+                cb.literal("C")
+        );
+
+        Expression fullDescriptionVec = cb.function("setweight", String.class,
+                new TSVectorFunction(root.get("fullDescription"), new RegconfigTypeCastOperatorFunction((NodeBuilder) cb, ENGLISH_CONFIGURATION, hibernateContext), (NodeBuilder) cb),
+                cb.literal("D")
+        );
+
+        // Concatenate tsvectors (|| operator)
+        SqmExpression fullVector = (SqmExpression) cb.concat(cb.concat(shortNameVec, fullNameVec), cb.concat(shortDescriptionVec, fullDescriptionVec));
+
+        // Build tsquery
+        Expression queryExpr = new WebsearchToTSQueryFunction((NodeBuilder) cb, ENGLISH_CONFIGURATION, phrase);
+
+        // WHERE clause using @@ operator
+        TextOperatorFunction matches = new TextOperatorFunction((NodeBuilder) cb, fullVector, new WebsearchToTSQueryFunction((NodeBuilder) cb, new RegconfigTypeCastOperatorFunction((NodeBuilder) cb, ENGLISH_CONFIGURATION, hibernateContext), phrase), hibernateContext);
+
+        cq.where(matches);
+
+        // Ranking
+        Expression rankExpr = cb.function(
+                "ts_rank_cd", Double.class,
+                fullVector,
+                queryExpr
+        );
+
+        cq.orderBy(ascSort ? cb.asc(rankExpr) : cb.desc(rankExpr));
+
+        return entityManager.createQuery(cq).getResultList();
+    }
+```
+
+This query produces SQL similar to:
+
+```sql
+select
+        i1_0.id,
+        i1_0.full_description,
+        i1_0.full_name,
+        i1_0.short_description,
+        i1_0.short_name 
+    from
+        item i1_0 
+    where
+        (
+            (
+                setweight(to_tsvector(?::regconfig, i1_0.short_name), 'A')||setweight(
+                    to_tsvector(?::regconfig, i1_0.full_name), 'B'
+                )
+            )||(
+                setweight(to_tsvector(?::regconfig, i1_0.short_description), 'C')||setweight(
+                    to_tsvector(?::regconfig, i1_0.full_description), 'D'
+                )
+            )
+        ) @@ websearch_to_tsquery(?::regconfig, ?) 
+    order by
+        ts_rank_cd(((setweight(to_tsvector(?::regconfig, i1_0.short_name), 'A')||setweight(to_tsvector(?::regconfig, i1_0.full_name), 'B'))||(setweight(to_tsvector(?::regconfig, i1_0.short_description), 'C')||setweight(to_tsvector(?::regconfig, i1_0.full_description), 'D'))), websearch_to_tsquery('english', ?))
+```
+
+Similar code but implemented with usage of HQL language:
+
+```java
+public List findItemsByWebSearchToTSQuerySortedByTsRankInHQL(String phrase, boolean ascSort) {
+        String statement = "from Item as item where " +
+                "text_operator_function(" + // text_operator_function - start
+                "concat(" + // main concat - start
+                "concat(" + // first concat - start
+                "function('setweight', to_tsvector('%1$s', item.shortName), 'A')" +
+                "," +
+                "function('setweight', to_tsvector('%1$s', item.fullName), 'B')" +
+                ")" + // first concat - end
+                "," + // main concat - separator
+                "concat(" + // second concat - start
+                "function('setweight', to_tsvector('%1$s', item.shortDescription), 'C')" +
+                "," +
+                "function('setweight', to_tsvector('%1$s', item.fullDescription), 'D')" +
+                ")" + // first second - end
+                ")" + // main concat - end
+                "," + // text_operator_function - separator
+
+                "websearch_to_tsquery(cast_operator_function('%1$s','regconfig'), :phrase)" + // websearch_to_tsquery operator
+
+                ")" + // text_operator_function - end
+                " order by " + // order - start
+
+
+                "function('ts_rank', " + // ts_rank function - start
+                "concat(" + // main concat - start
+                "concat(" + // first concat - start
+                "function('setweight', to_tsvector('%1$s', item.shortName), 'A')" +
+                "," +
+                "function('setweight', to_tsvector('%1$s', item.fullName), 'B')" +
+                ")" + // first concat - end
+                "," + // main concat - separator
+                "concat(" + // second concat - start
+                "function('setweight', to_tsvector('%1$s', item.shortDescription), 'C')" +
+                "," +
+                "function('setweight', to_tsvector('%1$s', item.fullDescription), 'D')" +
+                ")" + // first second - end
+                ")" + // main concat - end
+                "," + // ts_rank function - separator
+
+                "websearch_to_tsquery(cast_operator_function('%1$s','regconfig'), :phrase)" + // websearch_to_tsquery operator
+
+                ")" + // ts_rank function - end
+                (ascSort ? " asc" : "desc");
+
+        TypedQuery query = entityManager.createQuery(statement.formatted(ENGLISH_CONFIGURATION), Item.class);
+        query.setParameter("phrase", phrase);
+        return query.getResultList();
+    }
+```
+
 Component has also constructor to which developer can pass [the cast operator](#cast-operator-and-text-search-configuration)
 
 ### Properties

From 4cf34071e954a7454f4781f021c608ef5129a84a Mon Sep 17 00:00:00 2001
From: starnowski <33316705+starnowski@users.noreply.github.com>
Date: Sun, 19 Oct 2025 13:27:08 +0200
Subject: [PATCH 19/23] #158 - Fixed javadoc

---
 .../starnowski/posjsonhelper/core/Context.java   |  8 ++++----
 .../posjsonhelper/core/HibernateContext.java     |  8 ++++----
 .../posjsonhelper/core/sql/ISQLDefinition.java   |  2 +-
 .../AbstractFunctionDefinitionFactory.java       |  8 ++++----
 .../sql/functions/DefaultFunctionArgument.java   |  8 ++++----
 .../CastOperatorFunctionDescriptor.java          |  8 ++++----
 .../operators/CastOperatorFunction.java          |  8 ++++----
 .../Hibernate6JsonUpdateStatementBuilder.java    | 16 ++++++++--------
 .../AbstractJsonbArrayStringsExistPredicate.java |  2 +-
 .../DefaultJsonUpdateStatementOperationSort.java |  8 ++++----
 .../sql/JsonUpdateStatementConfiguration.java    |  8 ++++----
 .../JsonUpdateStatementConfigurationBuilder.java | 16 ++++++++--------
 ...figurationAndTextQueryFunctionDescriptor.java |  8 ++++----
 .../descriptor/TSVectorFunctionDescriptor.java   |  8 ++++----
 .../TextOperatorFunctionDescriptor.java          |  8 ++++----
 ...ionWithConfigurationAndTextQueryFunction.java | 16 ++++++++--------
 .../functions/PhraseToTSQueryFunction.java       |  8 ++++----
 .../functions/PlainToTSQueryFunction.java        |  8 ++++----
 .../hibernate6/functions/TSVectorFunction.java   |  8 ++++----
 .../functions/WebsearchToTSQueryFunction.java    |  8 ++++----
 .../RegconfigTypeCastOperatorFunction.java       |  8 ++++----
 .../operators/TextOperatorFunction.java          |  8 ++++----
 22 files changed, 94 insertions(+), 94 deletions(-)

diff --git a/core/src/main/java/com/github/starnowski/posjsonhelper/core/Context.java b/core/src/main/java/com/github/starnowski/posjsonhelper/core/Context.java
index a64831f1..61843e6c 100644
--- a/core/src/main/java/com/github/starnowski/posjsonhelper/core/Context.java
+++ b/core/src/main/java/com/github/starnowski/posjsonhelper/core/Context.java
@@ -1,19 +1,19 @@
 /**
  * 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 diff --git a/core/src/main/java/com/github/starnowski/posjsonhelper/core/HibernateContext.java b/core/src/main/java/com/github/starnowski/posjsonhelper/core/HibernateContext.java index 9b443070..1c8bc6e5 100644 --- a/core/src/main/java/com/github/starnowski/posjsonhelper/core/HibernateContext.java +++ b/core/src/main/java/com/github/starnowski/posjsonhelper/core/HibernateContext.java @@ -1,19 +1,19 @@ /** * 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 diff --git a/core/src/main/java/com/github/starnowski/posjsonhelper/core/sql/ISQLDefinition.java b/core/src/main/java/com/github/starnowski/posjsonhelper/core/sql/ISQLDefinition.java index dd4a4f31..4ff22de3 100644 --- a/core/src/main/java/com/github/starnowski/posjsonhelper/core/sql/ISQLDefinition.java +++ b/core/src/main/java/com/github/starnowski/posjsonhelper/core/sql/ISQLDefinition.java @@ -36,7 +36,7 @@ public interface ISQLDefinition { /** * Returns DDL statement that drops changes applied by statement returned by the {@link #getCreateScript()} method. - *

+ *

* IMPORTANT! *

* By default, there is no assumption that statement has to contains the compensation operation for operation returned by the {@link #getCreateScript()} method. diff --git a/core/src/main/java/com/github/starnowski/posjsonhelper/core/sql/functions/AbstractFunctionDefinitionFactory.java b/core/src/main/java/com/github/starnowski/posjsonhelper/core/sql/functions/AbstractFunctionDefinitionFactory.java index 1d2b7aea..54525a66 100644 --- a/core/src/main/java/com/github/starnowski/posjsonhelper/core/sql/functions/AbstractFunctionDefinitionFactory.java +++ b/core/src/main/java/com/github/starnowski/posjsonhelper/core/sql/functions/AbstractFunctionDefinitionFactory.java @@ -1,19 +1,19 @@ /** * 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 diff --git a/core/src/main/java/com/github/starnowski/posjsonhelper/core/sql/functions/DefaultFunctionArgument.java b/core/src/main/java/com/github/starnowski/posjsonhelper/core/sql/functions/DefaultFunctionArgument.java index d4f3395f..cc674a4d 100644 --- a/core/src/main/java/com/github/starnowski/posjsonhelper/core/sql/functions/DefaultFunctionArgument.java +++ b/core/src/main/java/com/github/starnowski/posjsonhelper/core/sql/functions/DefaultFunctionArgument.java @@ -1,19 +1,19 @@ /** * 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 diff --git a/hibernate6-core/src/main/java/com/github/starnowski/posjsonhelper/hibernate6/descriptor/CastOperatorFunctionDescriptor.java b/hibernate6-core/src/main/java/com/github/starnowski/posjsonhelper/hibernate6/descriptor/CastOperatorFunctionDescriptor.java index 9f6b560d..bf64fff0 100644 --- a/hibernate6-core/src/main/java/com/github/starnowski/posjsonhelper/hibernate6/descriptor/CastOperatorFunctionDescriptor.java +++ b/hibernate6-core/src/main/java/com/github/starnowski/posjsonhelper/hibernate6/descriptor/CastOperatorFunctionDescriptor.java @@ -1,19 +1,19 @@ /** * 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 diff --git a/hibernate6-core/src/main/java/com/github/starnowski/posjsonhelper/hibernate6/operators/CastOperatorFunction.java b/hibernate6-core/src/main/java/com/github/starnowski/posjsonhelper/hibernate6/operators/CastOperatorFunction.java index 0ace8079..857292e4 100644 --- a/hibernate6-core/src/main/java/com/github/starnowski/posjsonhelper/hibernate6/operators/CastOperatorFunction.java +++ b/hibernate6-core/src/main/java/com/github/starnowski/posjsonhelper/hibernate6/operators/CastOperatorFunction.java @@ -1,19 +1,19 @@ /** * 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 diff --git a/hibernate6/src/main/java/com/github/starnowski/posjsonhelper/hibernate6/Hibernate6JsonUpdateStatementBuilder.java b/hibernate6/src/main/java/com/github/starnowski/posjsonhelper/hibernate6/Hibernate6JsonUpdateStatementBuilder.java index a29ec497..e04b9601 100644 --- a/hibernate6/src/main/java/com/github/starnowski/posjsonhelper/hibernate6/Hibernate6JsonUpdateStatementBuilder.java +++ b/hibernate6/src/main/java/com/github/starnowski/posjsonhelper/hibernate6/Hibernate6JsonUpdateStatementBuilder.java @@ -1,19 +1,19 @@ /** * 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 @@ -73,7 +73,7 @@ * document = JsonPath.parse((Object) JsonPath.read(item.getJsonbContent(), "$")); * assertThat(document.jsonString()).isEqualTo("{\"child\":{\"pets\":[\"cat\"],\"birthday\":\"2021-11-23\"},\"parents\":[{\"name\":\"simone\",\"type\":\"mom\"}],\"inventory\":[\"fins\"],\"nicknames\":{\"school\":\"bambo\"}}"); * }

- *

+ *

* The above code is going to execute below sql statement for update: * *

{@code
@@ -95,8 +95,8 @@
  *     where
  *         id=?
  * }
- *

- *

+ *

+ *

* As it can be observed based on generated SQL, by default, the first operation is going to be an operation that deletes JSON content. * The most nested jsonb_set operation is going to set property "parents" with value "[]". * @@ -243,7 +243,7 @@ public Hibernate6JsonUpdateStatementBuilder withPostSortFilter(JsonUpdateS * JsonUpdateStatementOperation{jsonTextArray={parents,0}, operation=JSONB_SET, value='{"type":"mom", "name":"simone"}'} * ] * } - *

+ *

* The expression generated on such would be translated to below sql part: * *

{@code
diff --git a/hibernate6/src/main/java/com/github/starnowski/posjsonhelper/hibernate6/predicates/AbstractJsonbArrayStringsExistPredicate.java b/hibernate6/src/main/java/com/github/starnowski/posjsonhelper/hibernate6/predicates/AbstractJsonbArrayStringsExistPredicate.java
index 4692052a..ad543dac 100644
--- a/hibernate6/src/main/java/com/github/starnowski/posjsonhelper/hibernate6/predicates/AbstractJsonbArrayStringsExistPredicate.java
+++ b/hibernate6/src/main/java/com/github/starnowski/posjsonhelper/hibernate6/predicates/AbstractJsonbArrayStringsExistPredicate.java
@@ -44,7 +44,7 @@
  * 
{@code
  * {{main_func}}( jsonb_extract_path( generatedAlias0.jsonbContent , :param0 ) , json_function_json_array(:param1, :param2))
  * }
- *

+ *

* where: * {{main_func}} - name of main function returned by method {@link #getFunctionName()} * jsonb_extract_path( generatedAlias0.jsonbContent , :param0 ) - json path part, with this example path has only one element normally this could part could contain more elements "param" diff --git a/json-core/src/main/java/com/github/starnowski/posjsonhelper/json/core/sql/DefaultJsonUpdateStatementOperationSort.java b/json-core/src/main/java/com/github/starnowski/posjsonhelper/json/core/sql/DefaultJsonUpdateStatementOperationSort.java index b0fee5ee..a00cb3eb 100644 --- a/json-core/src/main/java/com/github/starnowski/posjsonhelper/json/core/sql/DefaultJsonUpdateStatementOperationSort.java +++ b/json-core/src/main/java/com/github/starnowski/posjsonhelper/json/core/sql/DefaultJsonUpdateStatementOperationSort.java @@ -1,19 +1,19 @@ /** * 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 diff --git a/json-core/src/main/java/com/github/starnowski/posjsonhelper/json/core/sql/JsonUpdateStatementConfiguration.java b/json-core/src/main/java/com/github/starnowski/posjsonhelper/json/core/sql/JsonUpdateStatementConfiguration.java index 43184097..4cf2be99 100644 --- a/json-core/src/main/java/com/github/starnowski/posjsonhelper/json/core/sql/JsonUpdateStatementConfiguration.java +++ b/json-core/src/main/java/com/github/starnowski/posjsonhelper/json/core/sql/JsonUpdateStatementConfiguration.java @@ -1,19 +1,19 @@ /** * 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 diff --git a/json-core/src/main/java/com/github/starnowski/posjsonhelper/json/core/sql/JsonUpdateStatementConfigurationBuilder.java b/json-core/src/main/java/com/github/starnowski/posjsonhelper/json/core/sql/JsonUpdateStatementConfigurationBuilder.java index 04185b87..95ff4268 100644 --- a/json-core/src/main/java/com/github/starnowski/posjsonhelper/json/core/sql/JsonUpdateStatementConfigurationBuilder.java +++ b/json-core/src/main/java/com/github/starnowski/posjsonhelper/json/core/sql/JsonUpdateStatementConfigurationBuilder.java @@ -1,19 +1,19 @@ /** * 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 @@ -49,7 +49,7 @@ * result.operations * System.out.println(result.operations) * }

- *

+ *

* It generates configuration with below operations: * *

{@code
@@ -60,7 +60,7 @@
  * JsonUpdateStatementOperation{jsonTextArray={parents,0}, operation=JSONB_SET, value='{"type":"mom", "name":"simone"}'}
  * ]
  * }
- *

+ *

* Assuming that we have database table "item" and column that stores json is called "jsonb_content" the update statement * would like as below example: * @@ -79,10 +79,10 @@ * WHERE * id=? * } - *

+ *

* In such a prepared statement, the top operation would set the "parents" property with an empty array. * The next operation will set the "child, birthday" property to "2021-11-23" and so on. - *

+ *

* For more details please check {@link #build()} method. */ public class JsonUpdateStatementConfigurationBuilder { diff --git a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/descriptor/AbstractFunctionWithConfigurationAndTextQueryFunctionDescriptor.java b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/descriptor/AbstractFunctionWithConfigurationAndTextQueryFunctionDescriptor.java index c319c3d5..721b9da0 100644 --- a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/descriptor/AbstractFunctionWithConfigurationAndTextQueryFunctionDescriptor.java +++ b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/descriptor/AbstractFunctionWithConfigurationAndTextQueryFunctionDescriptor.java @@ -1,19 +1,19 @@ /** * 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 diff --git a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/descriptor/TSVectorFunctionDescriptor.java b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/descriptor/TSVectorFunctionDescriptor.java index 87d469f4..3485500a 100644 --- a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/descriptor/TSVectorFunctionDescriptor.java +++ b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/descriptor/TSVectorFunctionDescriptor.java @@ -1,19 +1,19 @@ /** * 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 diff --git a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/descriptor/TextOperatorFunctionDescriptor.java b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/descriptor/TextOperatorFunctionDescriptor.java index c6e7f7f1..a6fe713e 100644 --- a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/descriptor/TextOperatorFunctionDescriptor.java +++ b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/descriptor/TextOperatorFunctionDescriptor.java @@ -1,19 +1,19 @@ /** * 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 diff --git a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/AbstractFunctionWithConfigurationAndTextQueryFunction.java b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/AbstractFunctionWithConfigurationAndTextQueryFunction.java index f63009ac..e05c79c5 100644 --- a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/AbstractFunctionWithConfigurationAndTextQueryFunction.java +++ b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/AbstractFunctionWithConfigurationAndTextQueryFunction.java @@ -1,19 +1,19 @@ /** * 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 @@ -40,15 +40,15 @@ *

{@code
  * {{main_func}}( :configuration, :text_query)
  * }
- *

- *

+ *

+ *

* Without configuration argument: * *

{@code
  * {{main_func}}( :text_query)
  * }
- *

- *

+ *

+ *

* where: * {{main_func}} - name of main function returned by method {@link #getFunctionName()} * :configuration - text search configuration diff --git a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/PhraseToTSQueryFunction.java b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/PhraseToTSQueryFunction.java index b2b4afa5..c0a8ecb6 100644 --- a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/PhraseToTSQueryFunction.java +++ b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/PhraseToTSQueryFunction.java @@ -1,19 +1,19 @@ /** * 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 diff --git a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/PlainToTSQueryFunction.java b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/PlainToTSQueryFunction.java index e6915565..b833fef9 100644 --- a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/PlainToTSQueryFunction.java +++ b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/PlainToTSQueryFunction.java @@ -1,19 +1,19 @@ /** * 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 diff --git a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/TSVectorFunction.java b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/TSVectorFunction.java index 442ea193..0d736127 100644 --- a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/TSVectorFunction.java +++ b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/TSVectorFunction.java @@ -1,19 +1,19 @@ /** * 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 diff --git a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/WebsearchToTSQueryFunction.java b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/WebsearchToTSQueryFunction.java index 0688b844..c5b24094 100644 --- a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/WebsearchToTSQueryFunction.java +++ b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/WebsearchToTSQueryFunction.java @@ -1,19 +1,19 @@ /** * 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 diff --git a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/operators/RegconfigTypeCastOperatorFunction.java b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/operators/RegconfigTypeCastOperatorFunction.java index a9351344..8840f080 100644 --- a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/operators/RegconfigTypeCastOperatorFunction.java +++ b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/operators/RegconfigTypeCastOperatorFunction.java @@ -1,19 +1,19 @@ /** * 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 diff --git a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/operators/TextOperatorFunction.java b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/operators/TextOperatorFunction.java index b74424d6..c9bf99a6 100644 --- a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/operators/TextOperatorFunction.java +++ b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/operators/TextOperatorFunction.java @@ -1,19 +1,19 @@ /** * 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 From 85701de44ab74438011cafe935eabf393af9edda Mon Sep 17 00:00:00 2001 From: starnowski <33316705+starnowski@users.noreply.github.com> Date: Sun, 19 Oct 2025 13:40:43 +0200 Subject: [PATCH 20/23] #158 - Fixed javadoc --- .../starnowski/posjsonhelper/core/Context.java | 8 ++++---- .../posjsonhelper/core/HibernateContext.java | 8 ++++---- .../posjsonhelper/core/sql/ISQLDefinition.java | 2 +- .../AbstractFunctionDefinitionFactory.java | 8 ++++---- .../sql/functions/DefaultFunctionArgument.java | 8 ++++---- .../CastOperatorFunctionDescriptor.java | 8 ++++---- .../operators/CastOperatorFunction.java | 8 ++++---- .../Hibernate6JsonUpdateStatementBuilder.java | 16 ++++++++-------- .../AbstractJsonbArrayStringsExistPredicate.java | 2 +- .../DefaultJsonUpdateStatementOperationSort.java | 8 ++++---- .../sql/JsonUpdateStatementConfiguration.java | 8 ++++---- .../JsonUpdateStatementConfigurationBuilder.java | 16 ++++++++-------- ...figurationAndTextQueryFunctionDescriptor.java | 8 ++++---- .../descriptor/TSVectorFunctionDescriptor.java | 8 ++++---- .../TextOperatorFunctionDescriptor.java | 8 ++++---- ...ionWithConfigurationAndTextQueryFunction.java | 16 ++++++++-------- .../functions/PhraseToTSQueryFunction.java | 8 ++++---- .../functions/PlainToTSQueryFunction.java | 8 ++++---- .../hibernate6/functions/TSVectorFunction.java | 8 ++++---- .../functions/WebsearchToTSQueryFunction.java | 8 ++++---- .../RegconfigTypeCastOperatorFunction.java | 8 ++++---- .../operators/TextOperatorFunction.java | 8 ++++---- 22 files changed, 94 insertions(+), 94 deletions(-) diff --git a/core/src/main/java/com/github/starnowski/posjsonhelper/core/Context.java b/core/src/main/java/com/github/starnowski/posjsonhelper/core/Context.java index 61843e6c..87a7c605 100644 --- a/core/src/main/java/com/github/starnowski/posjsonhelper/core/Context.java +++ b/core/src/main/java/com/github/starnowski/posjsonhelper/core/Context.java @@ -1,19 +1,19 @@ /** * 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 diff --git a/core/src/main/java/com/github/starnowski/posjsonhelper/core/HibernateContext.java b/core/src/main/java/com/github/starnowski/posjsonhelper/core/HibernateContext.java index 1c8bc6e5..0747eb94 100644 --- a/core/src/main/java/com/github/starnowski/posjsonhelper/core/HibernateContext.java +++ b/core/src/main/java/com/github/starnowski/posjsonhelper/core/HibernateContext.java @@ -1,19 +1,19 @@ /** * 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 diff --git a/core/src/main/java/com/github/starnowski/posjsonhelper/core/sql/ISQLDefinition.java b/core/src/main/java/com/github/starnowski/posjsonhelper/core/sql/ISQLDefinition.java index 4ff22de3..88d6fb2f 100644 --- a/core/src/main/java/com/github/starnowski/posjsonhelper/core/sql/ISQLDefinition.java +++ b/core/src/main/java/com/github/starnowski/posjsonhelper/core/sql/ISQLDefinition.java @@ -36,7 +36,7 @@ public interface ISQLDefinition { /** * Returns DDL statement that drops changes applied by statement returned by the {@link #getCreateScript()} method. - *

+ * * IMPORTANT! *

* By default, there is no assumption that statement has to contains the compensation operation for operation returned by the {@link #getCreateScript()} method. diff --git a/core/src/main/java/com/github/starnowski/posjsonhelper/core/sql/functions/AbstractFunctionDefinitionFactory.java b/core/src/main/java/com/github/starnowski/posjsonhelper/core/sql/functions/AbstractFunctionDefinitionFactory.java index 54525a66..5d6142cb 100644 --- a/core/src/main/java/com/github/starnowski/posjsonhelper/core/sql/functions/AbstractFunctionDefinitionFactory.java +++ b/core/src/main/java/com/github/starnowski/posjsonhelper/core/sql/functions/AbstractFunctionDefinitionFactory.java @@ -1,19 +1,19 @@ /** * 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 diff --git a/core/src/main/java/com/github/starnowski/posjsonhelper/core/sql/functions/DefaultFunctionArgument.java b/core/src/main/java/com/github/starnowski/posjsonhelper/core/sql/functions/DefaultFunctionArgument.java index cc674a4d..c76afd6e 100644 --- a/core/src/main/java/com/github/starnowski/posjsonhelper/core/sql/functions/DefaultFunctionArgument.java +++ b/core/src/main/java/com/github/starnowski/posjsonhelper/core/sql/functions/DefaultFunctionArgument.java @@ -1,19 +1,19 @@ /** * 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 diff --git a/hibernate6-core/src/main/java/com/github/starnowski/posjsonhelper/hibernate6/descriptor/CastOperatorFunctionDescriptor.java b/hibernate6-core/src/main/java/com/github/starnowski/posjsonhelper/hibernate6/descriptor/CastOperatorFunctionDescriptor.java index bf64fff0..1c1c77de 100644 --- a/hibernate6-core/src/main/java/com/github/starnowski/posjsonhelper/hibernate6/descriptor/CastOperatorFunctionDescriptor.java +++ b/hibernate6-core/src/main/java/com/github/starnowski/posjsonhelper/hibernate6/descriptor/CastOperatorFunctionDescriptor.java @@ -1,19 +1,19 @@ /** * 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 diff --git a/hibernate6-core/src/main/java/com/github/starnowski/posjsonhelper/hibernate6/operators/CastOperatorFunction.java b/hibernate6-core/src/main/java/com/github/starnowski/posjsonhelper/hibernate6/operators/CastOperatorFunction.java index 857292e4..2b04c3c7 100644 --- a/hibernate6-core/src/main/java/com/github/starnowski/posjsonhelper/hibernate6/operators/CastOperatorFunction.java +++ b/hibernate6-core/src/main/java/com/github/starnowski/posjsonhelper/hibernate6/operators/CastOperatorFunction.java @@ -1,19 +1,19 @@ /** * 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 diff --git a/hibernate6/src/main/java/com/github/starnowski/posjsonhelper/hibernate6/Hibernate6JsonUpdateStatementBuilder.java b/hibernate6/src/main/java/com/github/starnowski/posjsonhelper/hibernate6/Hibernate6JsonUpdateStatementBuilder.java index e04b9601..ac93792c 100644 --- a/hibernate6/src/main/java/com/github/starnowski/posjsonhelper/hibernate6/Hibernate6JsonUpdateStatementBuilder.java +++ b/hibernate6/src/main/java/com/github/starnowski/posjsonhelper/hibernate6/Hibernate6JsonUpdateStatementBuilder.java @@ -1,19 +1,19 @@ /** * 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 @@ -73,7 +73,7 @@ * document = JsonPath.parse((Object) JsonPath.read(item.getJsonbContent(), "$")); * assertThat(document.jsonString()).isEqualTo("{\"child\":{\"pets\":[\"cat\"],\"birthday\":\"2021-11-23\"},\"parents\":[{\"name\":\"simone\",\"type\":\"mom\"}],\"inventory\":[\"fins\"],\"nicknames\":{\"school\":\"bambo\"}}"); * } - *

+ * * The above code is going to execute below sql statement for update: * *

{@code
@@ -95,8 +95,8 @@
  *     where
  *         id=?
  * }
- *

- *

+ * + * * As it can be observed based on generated SQL, by default, the first operation is going to be an operation that deletes JSON content. * The most nested jsonb_set operation is going to set property "parents" with value "[]". * @@ -243,7 +243,7 @@ public Hibernate6JsonUpdateStatementBuilder withPostSortFilter(JsonUpdateS * JsonUpdateStatementOperation{jsonTextArray={parents,0}, operation=JSONB_SET, value='{"type":"mom", "name":"simone"}'} * ] * } - *

+ * * The expression generated on such would be translated to below sql part: * *

{@code
diff --git a/hibernate6/src/main/java/com/github/starnowski/posjsonhelper/hibernate6/predicates/AbstractJsonbArrayStringsExistPredicate.java b/hibernate6/src/main/java/com/github/starnowski/posjsonhelper/hibernate6/predicates/AbstractJsonbArrayStringsExistPredicate.java
index ad543dac..5f6cf5b2 100644
--- a/hibernate6/src/main/java/com/github/starnowski/posjsonhelper/hibernate6/predicates/AbstractJsonbArrayStringsExistPredicate.java
+++ b/hibernate6/src/main/java/com/github/starnowski/posjsonhelper/hibernate6/predicates/AbstractJsonbArrayStringsExistPredicate.java
@@ -44,7 +44,7 @@
  * 
{@code
  * {{main_func}}( jsonb_extract_path( generatedAlias0.jsonbContent , :param0 ) , json_function_json_array(:param1, :param2))
  * }
- *

+ * * where: * {{main_func}} - name of main function returned by method {@link #getFunctionName()} * jsonb_extract_path( generatedAlias0.jsonbContent , :param0 ) - json path part, with this example path has only one element normally this could part could contain more elements "param" diff --git a/json-core/src/main/java/com/github/starnowski/posjsonhelper/json/core/sql/DefaultJsonUpdateStatementOperationSort.java b/json-core/src/main/java/com/github/starnowski/posjsonhelper/json/core/sql/DefaultJsonUpdateStatementOperationSort.java index a00cb3eb..aee125b1 100644 --- a/json-core/src/main/java/com/github/starnowski/posjsonhelper/json/core/sql/DefaultJsonUpdateStatementOperationSort.java +++ b/json-core/src/main/java/com/github/starnowski/posjsonhelper/json/core/sql/DefaultJsonUpdateStatementOperationSort.java @@ -1,19 +1,19 @@ /** * 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 diff --git a/json-core/src/main/java/com/github/starnowski/posjsonhelper/json/core/sql/JsonUpdateStatementConfiguration.java b/json-core/src/main/java/com/github/starnowski/posjsonhelper/json/core/sql/JsonUpdateStatementConfiguration.java index 4cf2be99..ef965144 100644 --- a/json-core/src/main/java/com/github/starnowski/posjsonhelper/json/core/sql/JsonUpdateStatementConfiguration.java +++ b/json-core/src/main/java/com/github/starnowski/posjsonhelper/json/core/sql/JsonUpdateStatementConfiguration.java @@ -1,19 +1,19 @@ /** * 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 diff --git a/json-core/src/main/java/com/github/starnowski/posjsonhelper/json/core/sql/JsonUpdateStatementConfigurationBuilder.java b/json-core/src/main/java/com/github/starnowski/posjsonhelper/json/core/sql/JsonUpdateStatementConfigurationBuilder.java index 95ff4268..5c5580e4 100644 --- a/json-core/src/main/java/com/github/starnowski/posjsonhelper/json/core/sql/JsonUpdateStatementConfigurationBuilder.java +++ b/json-core/src/main/java/com/github/starnowski/posjsonhelper/json/core/sql/JsonUpdateStatementConfigurationBuilder.java @@ -1,19 +1,19 @@ /** * 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 @@ -49,7 +49,7 @@ * result.operations * System.out.println(result.operations) * }

- *

+ * * It generates configuration with below operations: * *

{@code
@@ -60,7 +60,7 @@
  * JsonUpdateStatementOperation{jsonTextArray={parents,0}, operation=JSONB_SET, value='{"type":"mom", "name":"simone"}'}
  * ]
  * }
- *

+ * * Assuming that we have database table "item" and column that stores json is called "jsonb_content" the update statement * would like as below example: * @@ -79,10 +79,10 @@ * WHERE * id=? * } - *

+ * * In such a prepared statement, the top operation would set the "parents" property with an empty array. * The next operation will set the "child, birthday" property to "2021-11-23" and so on. - *

+ * * For more details please check {@link #build()} method. */ public class JsonUpdateStatementConfigurationBuilder { diff --git a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/descriptor/AbstractFunctionWithConfigurationAndTextQueryFunctionDescriptor.java b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/descriptor/AbstractFunctionWithConfigurationAndTextQueryFunctionDescriptor.java index 721b9da0..c2f868b9 100644 --- a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/descriptor/AbstractFunctionWithConfigurationAndTextQueryFunctionDescriptor.java +++ b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/descriptor/AbstractFunctionWithConfigurationAndTextQueryFunctionDescriptor.java @@ -1,19 +1,19 @@ /** * 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 diff --git a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/descriptor/TSVectorFunctionDescriptor.java b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/descriptor/TSVectorFunctionDescriptor.java index 3485500a..4a237d4a 100644 --- a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/descriptor/TSVectorFunctionDescriptor.java +++ b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/descriptor/TSVectorFunctionDescriptor.java @@ -1,19 +1,19 @@ /** * 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 diff --git a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/descriptor/TextOperatorFunctionDescriptor.java b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/descriptor/TextOperatorFunctionDescriptor.java index a6fe713e..17bbd495 100644 --- a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/descriptor/TextOperatorFunctionDescriptor.java +++ b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/descriptor/TextOperatorFunctionDescriptor.java @@ -1,19 +1,19 @@ /** * 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 diff --git a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/AbstractFunctionWithConfigurationAndTextQueryFunction.java b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/AbstractFunctionWithConfigurationAndTextQueryFunction.java index e05c79c5..95a340d6 100644 --- a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/AbstractFunctionWithConfigurationAndTextQueryFunction.java +++ b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/AbstractFunctionWithConfigurationAndTextQueryFunction.java @@ -1,19 +1,19 @@ /** * 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 @@ -40,15 +40,15 @@ *

{@code
  * {{main_func}}( :configuration, :text_query)
  * }
- *

- *

+ * + * * Without configuration argument: * *

{@code
  * {{main_func}}( :text_query)
  * }
- *

- *

+ * + * * where: * {{main_func}} - name of main function returned by method {@link #getFunctionName()} * :configuration - text search configuration diff --git a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/PhraseToTSQueryFunction.java b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/PhraseToTSQueryFunction.java index c0a8ecb6..71c29765 100644 --- a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/PhraseToTSQueryFunction.java +++ b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/PhraseToTSQueryFunction.java @@ -1,19 +1,19 @@ /** * 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 diff --git a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/PlainToTSQueryFunction.java b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/PlainToTSQueryFunction.java index b833fef9..73c52d45 100644 --- a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/PlainToTSQueryFunction.java +++ b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/PlainToTSQueryFunction.java @@ -1,19 +1,19 @@ /** * 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 diff --git a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/TSVectorFunction.java b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/TSVectorFunction.java index 0d736127..af2f5d7d 100644 --- a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/TSVectorFunction.java +++ b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/TSVectorFunction.java @@ -1,19 +1,19 @@ /** * 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 diff --git a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/WebsearchToTSQueryFunction.java b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/WebsearchToTSQueryFunction.java index c5b24094..94165c0b 100644 --- a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/WebsearchToTSQueryFunction.java +++ b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/functions/WebsearchToTSQueryFunction.java @@ -1,19 +1,19 @@ /** * 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 diff --git a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/operators/RegconfigTypeCastOperatorFunction.java b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/operators/RegconfigTypeCastOperatorFunction.java index 8840f080..57d4e932 100644 --- a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/operators/RegconfigTypeCastOperatorFunction.java +++ b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/operators/RegconfigTypeCastOperatorFunction.java @@ -1,19 +1,19 @@ /** * 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 diff --git a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/operators/TextOperatorFunction.java b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/operators/TextOperatorFunction.java index c9bf99a6..7c55be52 100644 --- a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/operators/TextOperatorFunction.java +++ b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/operators/TextOperatorFunction.java @@ -1,19 +1,19 @@ /** * 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 From fa665d3ba6952c820aec47306f9ce90f81065164 Mon Sep 17 00:00:00 2001 From: starnowski <33316705+starnowski@users.noreply.github.com> Date: Sun, 19 Oct 2025 13:41:22 +0200 Subject: [PATCH 21/23] #158 - Fixed javadoc --- .../hibernate6/operators/TextOperatorFunction.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/operators/TextOperatorFunction.java b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/operators/TextOperatorFunction.java index 7c55be52..697ad156 100644 --- a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/operators/TextOperatorFunction.java +++ b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/operators/TextOperatorFunction.java @@ -1,19 +1,19 @@ /** * 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 @@ -22,7 +22,6 @@ package com.github.starnowski.posjsonhelper.text.hibernate6.operators; import com.github.starnowski.posjsonhelper.core.HibernateContext; -import com.github.starnowski.posjsonhelper.text.hibernate6.functions.TSVectorFunction; import org.hibernate.query.sqm.NodeBuilder; import org.hibernate.query.sqm.function.FunctionRenderer; import org.hibernate.query.sqm.function.SelfRenderingSqmFunction; @@ -49,7 +48,7 @@ public class TextOperatorFunction extends SelfRenderingSqmFunction impl /** * @param nodeBuilder component of type {@link NodeBuilder} - * @param tsVectorFunction object of type {@link TSVectorFunction} + * @param tsVectorFunction object of type {@link SqmExpression} * @param argument text query expression * @param hibernateContext context object of type {@link HibernateContext} */ From 6f6c5b7b90267313d3df1502c58d3bb913ff7600 Mon Sep 17 00:00:00 2001 From: starnowski <33316705+starnowski@users.noreply.github.com> Date: Sun, 19 Oct 2025 13:44:27 +0200 Subject: [PATCH 22/23] #158 - Fixed javadoc --- .../starnowski/posjsonhelper/core/sql/ISQLDefinition.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/com/github/starnowski/posjsonhelper/core/sql/ISQLDefinition.java b/core/src/main/java/com/github/starnowski/posjsonhelper/core/sql/ISQLDefinition.java index 88d6fb2f..6952aff4 100644 --- a/core/src/main/java/com/github/starnowski/posjsonhelper/core/sql/ISQLDefinition.java +++ b/core/src/main/java/com/github/starnowski/posjsonhelper/core/sql/ISQLDefinition.java @@ -38,7 +38,7 @@ public interface ISQLDefinition { * Returns DDL statement that drops changes applied by statement returned by the {@link #getCreateScript()} method. * * IMPORTANT! - *

+ * * By default, there is no assumption that statement has to contains the compensation operation for operation returned by the {@link #getCreateScript()} method. * This means that the operation can not be by default treated as a rollback operation, but an operation that removes changes applied by statement returned by the {@link #getCreateScript()} method. * @return DDL statement that drops changes applied by statement returned by the {@link #getCreateScript()} method. From 8b2070a4934bb26d15b0b0b5fca18250775f2ee8 Mon Sep 17 00:00:00 2001 From: starnowski <33316705+starnowski@users.noreply.github.com> Date: Sun, 19 Oct 2025 13:49:46 +0200 Subject: [PATCH 23/23] #158 - Fixed javadoc --- .../hibernate6/descriptor/TextOperatorFunctionDescriptor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/descriptor/TextOperatorFunctionDescriptor.java b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/descriptor/TextOperatorFunctionDescriptor.java index 17bbd495..14873715 100644 --- a/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/descriptor/TextOperatorFunctionDescriptor.java +++ b/text/hibernate6-text/src/main/java/com/github/starnowski/posjsonhelper/text/hibernate6/descriptor/TextOperatorFunctionDescriptor.java @@ -40,7 +40,7 @@ /** * Function descriptor for text postgres operator. - * Generally it renders passed arguments that one is SqmExpression object type and second is expression that represents text query. + * Generally it renders passed arguments that one is SqmExpression object type and second is expression that represents text query. * For example: * SQL *
{@code