Skip to content

Commit

Permalink
[Blazebit#1413] Add support for Hibernate 5.6.3 through a custom inte…
Browse files Browse the repository at this point in the history
…gration. Also fire CDI event for CriteriaBuilderConfiguration in Quarkus integration
  • Loading branch information
beikov committed Nov 4, 2024
1 parent 9a64319 commit 7b3aaab
Show file tree
Hide file tree
Showing 53 changed files with 3,958 additions and 70 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Not yet released

### New features

* None yet
* Fire CDI event for `CriteriaBuilderConfiguration` on boot also in Quarkus integration
* Create custom integrations for Hibernate 5.5 and 5.6 to avoid confusion

### Bug fixes

Expand All @@ -18,6 +19,7 @@ Not yet released
### Backwards-incompatible changes

* Throw exception if non-streaming capable object builder is used for streaming
* Replace `blaze-persistence-integration-hibernate-5.4-jakarta` with `blaze-persistence-integration-hibernate-5.5-jakarta`

## 1.6.4

Expand Down
18 changes: 9 additions & 9 deletions core/testsuite/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1669,7 +1669,7 @@
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>blaze-persistence-integration-hibernate-5.4</artifactId>
<artifactId>blaze-persistence-integration-hibernate-5.5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -1801,7 +1801,7 @@
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>blaze-persistence-integration-hibernate-5.4</artifactId>
<artifactId>blaze-persistence-integration-hibernate-5.6</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -2694,26 +2694,26 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${version.hibernate-5.4}</version>
<version>${version.hibernate-5.6}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-envers</artifactId>
<version>${version.hibernate-5.4}</version>
<version>${version.hibernate-5.6}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-testing</artifactId>
<version>${version.hibernate-5.4}</version>
<version>${version.hibernate-5.6}</version>
</dependency>
<dependency>
<groupId>com.vladmihalcea</groupId>
<artifactId>hibernate-types-52</artifactId>
<artifactId>hibernate-types-55</artifactId>
<version>${version.hibernate-types}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>blaze-persistence-integration-hibernate-5.4</artifactId>
<artifactId>blaze-persistence-integration-hibernate-5.6</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -2725,7 +2725,7 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>${version.hibernate-5.4}</version>
<version>${version.hibernate-5.6}</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -2789,7 +2789,7 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>${version.hibernate-5.4}</version>
<version>${version.hibernate-5.6}</version>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
Expand Down
20 changes: 19 additions & 1 deletion dist/bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,25 @@
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>blaze-persistence-integration-hibernate-5.4-jakarta</artifactId>
<artifactId>blaze-persistence-integration-hibernate-5.5</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>blaze-persistence-integration-hibernate-5.5-jakarta</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>blaze-persistence-integration-hibernate-5.6</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>blaze-persistence-integration-hibernate-5.6-jakarta</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
Expand Down
16 changes: 16 additions & 0 deletions dist/full/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,22 @@
<groupId>${project.groupId}</groupId>
<artifactId>blaze-persistence-integration-hibernate-5.4</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>blaze-persistence-integration-hibernate-5.5</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>blaze-persistence-integration-hibernate-5.5-jakarta</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>blaze-persistence-integration-hibernate-5.6</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>blaze-persistence-integration-hibernate-5.6-jakarta</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>blaze-persistence-integration-hibernate-6.0</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,25 +76,60 @@ or if you are using Jakarta JPA

Depending on the JPA provider that should be used, one of the following integrations is required

[[maven-setup-hibernate54-jakarta]]
===== Hibernate 5.4+ Jakarta
[[maven-setup-hibernate56-jakarta]]
===== Hibernate 5.6+ Jakarta

This integration works for Hibernate 5.4, 5.5 and 5.6
[source,xml]
----
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-hibernate-5.6-jakarta</artifactId>
<version>${blaze-persistence.version}</version>
<scope>runtime</scope>
</dependency>
----

[[maven-setup-hibernate56]]
===== Hibernate 5.6

[source,xml]
----
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-hibernate-5.4-jakarta</artifactId>
<artifactId>blaze-persistence-integration-hibernate-5.6</artifactId>
<version>${blaze-persistence.version}</version>
<scope>runtime</scope>
</dependency>
----

[[maven-setup-hibernate54]]
===== Hibernate 5.4+
[[maven-setup-hibernate55-jakarta]]
===== Hibernate 5.5 Jakarta

[source,xml]
----
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-hibernate-5.5-jakarta</artifactId>
<version>${blaze-persistence.version}</version>
<scope>runtime</scope>
</dependency>
----

This integration works for Hibernate 5.4, 5.5 and 5.6
[[maven-setup-hibernate55]]
===== Hibernate 5.5

[source,xml]
----
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-hibernate-5.5</artifactId>
<version>${blaze-persistence.version}</version>
<scope>runtime</scope>
</dependency>
----

[[maven-setup-hibernate54]]
===== Hibernate 5.4

[source,xml]
----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ As outlined in the <<maven-querydsl-setup,setup section>> you need the following
</dependency>
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-hibernate-5.4</artifactId>
<artifactId>blaze-persistence-integration-hibernate-5.6</artifactId>
<version>${blaze-persistence.version}</version>
<scope>runtime</scope>
</dependency>
Expand All @@ -49,7 +49,7 @@ or if you are using Jakarta JPA
</dependency>
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-hibernate-5.4-jakarta</artifactId>
<artifactId>blaze-persistence-integration-hibernate-5.6-jakarta</artifactId>
<version>${blaze-persistence.version}</version>
<scope>runtime</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,21 @@ In order to make proper use of a custom type in entity views, it is necessary to

Configure default values for optional parameters::
Sometimes it is useful to provide access to services into entity views through optional parameters, for which a global default value can be registered on `EntityViewConfiguration`.

As of version 1.6.5, also a CDI event of the type `CriteriaBuilderConfiguration` is fired with an optional `@BlazePersistenceInstance` qualifier at boot time.
This allows to further customize the configuration which is often necessary if the context-less variant `CriteriaBuilderConfigurationContributor` isn't enough

Register named type for VALUES::
If you want to use a type that isn't supported out of the box, it needs to be registered under a name.

Register custom JpqlFunctionGroup::
If you want to register a CDI context aware `JpqlFunctionGroup`.

Register JpqlMacro::
If you want to register a CDI context aware `JpqlMacro`.

Register custom dialect::
When a dialect has a bug, needs a customization, or a new kind of dialect should be registered.

Configure properties::
Sometimes it is simply necessary to override a configuration property through `setProperty`
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ In short, the following Maven dependencies are required
</dependency>
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-hibernate-5.4</artifactId>
<artifactId>blaze-persistence-integration-hibernate-5.6</artifactId>
<version>${blaze-persistence.version}</version>
<scope>runtime</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ In short, the following Maven dependencies are required
</dependency>
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-hibernate-5.4</artifactId>
<artifactId>blaze-persistence-integration-hibernate-5.6</artifactId>
<version>${blaze-persistence.version}</version>
<scope>runtime</scope>
</dependency>
Expand Down
12 changes: 6 additions & 6 deletions entity-view/testsuite/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,7 @@
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>blaze-persistence-integration-hibernate-5.4</artifactId>
<artifactId>blaze-persistence-integration-hibernate-5.5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -1349,7 +1349,7 @@
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>blaze-persistence-integration-hibernate-5.4</artifactId>
<artifactId>blaze-persistence-integration-hibernate-5.6</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -2176,11 +2176,11 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${version.hibernate-5.4}</version>
<version>${version.hibernate-5.6}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>blaze-persistence-integration-hibernate-5.4</artifactId>
<artifactId>blaze-persistence-integration-hibernate-5.6</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -2192,7 +2192,7 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>${version.hibernate-5.4}</version>
<version>${version.hibernate-5.6}</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -2234,7 +2234,7 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>${version.hibernate-5.4}</version>
<version>${version.hibernate-5.6}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

package com.blazebit.persistence.examples.quarkus.base.config;

import com.blazebit.persistence.spi.CriteriaBuilderConfiguration;
import com.blazebit.persistence.spi.FunctionRenderContext;
import com.blazebit.persistence.spi.JpqlMacro;
import com.blazebit.persistence.view.spi.EntityViewConfiguration;

import javax.enterprise.context.ApplicationScoped;
Expand All @@ -24,6 +27,15 @@
@ApplicationScoped
public class BlazePersistenceConfigurator {

public void observe(@Observes CriteriaBuilderConfiguration config) {
config.registerMacro("my_macro", new JpqlMacro() {
@Override
public void render(FunctionRenderContext context) {
context.addArgument(0);
}
});
}

public void observe(@Observes EntityViewConfiguration config) {
config.setOptionalParameter("optionalParameter", "test");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,7 @@ public interface DocumentView {

@MappingParameter("optionalParameter")
String getOptionalParameter();

@Mapping("my_macro(name)")
String getMacroName();
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public void getDocumentsWithJsonIgnoredName() {

assertFalse(document.containsKey("name"));
assertEquals("test", document.get("optionalParameter"));
assertEquals("Doc1", document.get("macroName"));
}

@Test
Expand Down
Loading

0 comments on commit 7b3aaab

Please sign in to comment.