Skip to content

Commit 27eb0f5

Browse files
committed
hibenate 7
1 parent 68b6d84 commit 27eb0f5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+7486
-3
lines changed

hibernate4/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ Hibernate (https://hibernate.org) version 4.x data types.
6363

6464
<build>
6565
<plugins>
66+
<plugin>
67+
<groupId>org.apache.maven.plugins</groupId>
68+
<artifactId>maven-compiler-plugin</artifactId>
69+
<configuration>
70+
<source>8</source>
71+
<target>8</target>
72+
</configuration>
73+
</plugin>
6674
<plugin>
6775
<!-- Inherited from oss-base. Generate PackageVersion.java.-->
6876
<groupId>com.google.code.maven-replacer-plugin</groupId>

hibernate5-jakarta/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@ Hibernate (https://hibernate.org) version 5.5 with Jakarta data types.
8080

8181
<build>
8282
<plugins>
83+
<plugin>
84+
<groupId>org.apache.maven.plugins</groupId>
85+
<artifactId>maven-compiler-plugin</artifactId>
86+
<configuration>
87+
<source>8</source>
88+
<target>8</target>
89+
</configuration>
90+
</plugin>
8391
<plugin>
8492
<!-- Inherited from oss-base. Generate PackageVersion.java.-->
8593
<groupId>com.google.code.maven-replacer-plugin</groupId>

hibernate5/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@ Hibernate (https://hibernate.org) version 5.x data types.
9797

9898
<build>
9999
<plugins>
100+
<plugin>
101+
<groupId>org.apache.maven.plugins</groupId>
102+
<artifactId>maven-compiler-plugin</artifactId>
103+
<configuration>
104+
<source>8</source>
105+
<target>8</target>
106+
</configuration>
107+
</plugin>
100108
<plugin>
101109
<!-- Inherited from oss-base. Generate PackageVersion.java.-->
102110
<groupId>com.google.code.maven-replacer-plugin</groupId>

hibernate5_2-test/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@
6161
</dependencies>
6262
<build>
6363
<plugins>
64+
<plugin>
65+
<groupId>org.apache.maven.plugins</groupId>
66+
<artifactId>maven-compiler-plugin</artifactId>
67+
<configuration>
68+
<source>8</source>
69+
<target>8</target>
70+
</configuration>
71+
</plugin>
6472
<plugin>
6573
<!-- Don't generate a jar -->
6674
<groupId>org.apache.maven.plugins</groupId>

hibernate6/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ Hibernate (https://hibernate.org/) version 6.x with Jakarta data types.
7272

7373
<build>
7474
<plugins>
75+
<plugin>
76+
<groupId>org.apache.maven.plugins</groupId>
77+
<artifactId>maven-compiler-plugin</artifactId>
78+
<configuration>
79+
<source>8</source>
80+
<target>8</target>
81+
</configuration>
82+
</plugin>
7583
<plugin>
7684
<!-- Inherited from oss-base. Generate PackageVersion.java.-->
7785
<groupId>com.google.code.maven-replacer-plugin</groupId>

hibernate7/pom.xml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<!-- This module was also published with a richer model, Gradle metadata, -->
3+
<!-- which should be used instead. Do not delete the following line which -->
4+
<!-- is to indicate to Gradle or any Gradle module metadata file consumer -->
5+
<!-- that they should prefer consuming it instead. -->
6+
<!-- do_not_remove: published-with-gradle-metadata -->
7+
<modelVersion>4.0.0</modelVersion>
8+
<parent>
9+
<groupId>com.fasterxml.jackson.datatype</groupId>
10+
<artifactId>jackson-datatype-hibernate-parent</artifactId>
11+
<version>2.20.0-SNAPSHOT</version>
12+
</parent>
13+
<artifactId>jackson-datatype-hibernate7</artifactId>
14+
<name>Jackson-datatype-hibernate7</name>
15+
<packaging>bundle</packaging>
16+
<description>Add-on module for Jackson (https://github.com/FasterXML/jackson) to support
17+
Hibernate (https://hibernate.org/) version 7.x with Jakarta data types.
18+
</description>
19+
<url>https://github.com/FasterXML/jackson-datatype-hibernate</url>
20+
<properties>
21+
<!-- Generate PackageVersion.java into this directory. -->
22+
<packageVersion.dir>com/fasterxml/jackson/datatype/hibernate7</packageVersion.dir>
23+
<packageVersion.package>${project.groupId}.hibernate7</packageVersion.package>
24+
<!-- Hibernate with Jakarta Persistence 3.0 -->
25+
<hibernate.version>7.0.3.Final</hibernate.version>
26+
<osgi.export>${project.groupId}.hibernate7</osgi.export>
27+
</properties>
28+
29+
<dependencies>
30+
<dependency>
31+
<groupId>jakarta.transaction</groupId>
32+
<artifactId>jakarta.transaction-api</artifactId>
33+
<version>2.0.1</version>
34+
</dependency>
35+
36+
<!-- what would be the best scope to use here? -->
37+
<dependency>
38+
<groupId>org.hibernate.orm</groupId>
39+
<artifactId>hibernate-core</artifactId>
40+
<version>${hibernate.version}</version>
41+
<scope>provided</scope>
42+
</dependency>
43+
44+
<!-- and for some contributed tests Mockito -->
45+
<dependency>
46+
<groupId>org.mockito</groupId>
47+
<artifactId>mockito-core</artifactId>
48+
<scope>test</scope>
49+
</dependency>
50+
<dependency>
51+
<groupId>org.slf4j</groupId>
52+
<artifactId>slf4j-log4j12</artifactId>
53+
<scope>test</scope>
54+
</dependency>
55+
<dependency>
56+
<groupId>log4j</groupId>
57+
<artifactId>log4j</artifactId>
58+
<scope>test</scope>
59+
</dependency>
60+
<dependency>
61+
<groupId>com.h2database</groupId>
62+
<artifactId>h2</artifactId>
63+
<scope>test</scope>
64+
</dependency>
65+
<dependency>
66+
<groupId>jakarta.xml.bind</groupId>
67+
<artifactId>jakarta.xml.bind-api</artifactId>
68+
<version>3.0.1</version>
69+
<scope>test</scope>
70+
</dependency>
71+
</dependencies>
72+
73+
<build>
74+
<plugins>
75+
<plugin>
76+
<groupId>org.apache.maven.plugins</groupId>
77+
<artifactId>maven-compiler-plugin</artifactId>
78+
<configuration>
79+
<source>17</source>
80+
<target>17</target>
81+
</configuration>
82+
</plugin>
83+
<plugin>
84+
<!-- Inherited from oss-base. Generate PackageVersion.java.-->
85+
<groupId>com.google.code.maven-replacer-plugin</groupId>
86+
<artifactId>replacer</artifactId>
87+
</plugin>
88+
<!-- 29-Apr-2025, tatu: SBOM generation [JSTEP-14] -->
89+
<plugin>
90+
<groupId>org.cyclonedx</groupId>
91+
<artifactId>cyclonedx-maven-plugin</artifactId>
92+
</plugin>
93+
<plugin>
94+
<groupId>org.moditect</groupId>
95+
<artifactId>moditect-maven-plugin</artifactId>
96+
<inherited>true</inherited>
97+
<configuration>
98+
<jvmVersion>11</jvmVersion>
99+
</configuration>
100+
</plugin>
101+
<!-- 05-Jul-2020, tatu: Add generation of Gradle Module Metadata -->
102+
<!-- 28-Feb-2025, jjohannes: Apply plugin last as it has to be the last of all 'package phase' plugins -->
103+
<plugin>
104+
<groupId>org.gradlex</groupId>
105+
<artifactId>gradle-module-metadata-maven-plugin</artifactId>
106+
</plugin>
107+
</plugins>
108+
</build>
109+
</project>
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
package com.fasterxml.jackson.datatype.hibernate7;
2+
3+
import com.fasterxml.jackson.core.Version;
4+
import com.fasterxml.jackson.databind.AnnotationIntrospector;
5+
import com.fasterxml.jackson.databind.introspect.AnnotatedClass;
6+
import com.fasterxml.jackson.databind.introspect.AnnotatedMember;
7+
import jakarta.persistence.Transient;
8+
9+
/**
10+
* Simple {@link AnnotationIntrospector} that adds support for using
11+
* {@link Transient} to denote ignorable fields (alongside with Jackson
12+
* and/or JAXB annotations).
13+
*/
14+
public class Hibernate7AnnotationIntrospector extends AnnotationIntrospector
15+
{
16+
private static final long serialVersionUID = 1L;
17+
18+
/**
19+
* Whether we should check for existence of @Transient or not.
20+
* Default value is 'true'.
21+
*/
22+
protected boolean _cfgCheckTransient = true;
23+
24+
/*
25+
/**********************************************************************
26+
/* Construction, configuration
27+
/**********************************************************************
28+
*/
29+
30+
public Hibernate7AnnotationIntrospector() { }
31+
32+
/**
33+
* Method to call to specify whether @Transient annotation is to be
34+
* supported; if false, will be ignored, if true, will be used to
35+
* detect "ignorable" properties.
36+
*/
37+
public Hibernate7AnnotationIntrospector setUseTransient(boolean state) {
38+
_cfgCheckTransient = state;
39+
return this;
40+
}
41+
42+
/**
43+
* @since 2.5
44+
*/
45+
public boolean doesUseTransient() {
46+
return _cfgCheckTransient;
47+
}
48+
49+
/*
50+
/**********************************************************************
51+
/* Standard method impl/overrides
52+
/**********************************************************************
53+
*/
54+
55+
@Override
56+
public Version version() {
57+
return PackageVersion.VERSION;
58+
}
59+
60+
/*
61+
/**********************************************************************
62+
/* Annotation introspection methods
63+
/**********************************************************************
64+
*/
65+
66+
@Override
67+
public boolean hasIgnoreMarker(AnnotatedMember m) {
68+
return _cfgCheckTransient && m.hasAnnotation(Transient.class);
69+
}
70+
71+
@Override
72+
public Boolean isIgnorableType(AnnotatedClass ac)
73+
{
74+
/* 26-Dec-2015, tatu: To fix [datatype-hibernate#72], need to suppress handling
75+
* of `FieldHandled`. Not sure if it works without test (alas, none provided),
76+
* but will try our best -- problem is, if it'
77+
*/
78+
// 11-Feb-2016, tatu: As per [datatype-hibernate#86] must use indirection. Sigh.
79+
Class<?> handlerClass = FieldHandlerChecker.instance.getHandlerClass();
80+
if (handlerClass != null) {
81+
if (handlerClass.isAssignableFrom(ac.getAnnotated())) {
82+
return Boolean.TRUE;
83+
}
84+
}
85+
return null;
86+
}
87+
88+
/**
89+
* Helper class used to encapsulate detection of <code>FieldHandler</code>; class
90+
* that was part of Hibernate from 4.0 until 5.0, but removed from 5.1.
91+
*/
92+
final static class FieldHandlerChecker {
93+
private final static String FIELD_HANDLER_INTERFACE = "org.hibernate.bytecode.internal.javassist.FieldHandler";
94+
95+
private final Class<?> _handlerClass;
96+
97+
public final static FieldHandlerChecker instance = new FieldHandlerChecker();
98+
99+
public FieldHandlerChecker() {
100+
Class<?> cls = null;
101+
try {
102+
cls = Class.forName(FIELD_HANDLER_INTERFACE);
103+
} catch (Throwable t) { }
104+
_handlerClass = cls;
105+
}
106+
107+
public Class<?> getHandlerClass() {
108+
return _handlerClass;
109+
}
110+
}
111+
}

0 commit comments

Comments
 (0)