Hibernate ORM: creating branch 5.5, long live 5.6
by Sanne Grinovero
Hi all,
While the Hibernate ORM core experts are focused on Hibernate ORM 6, we
have a small team working on Hibernate Reactive that needs some more
changes done on Hibernate ORM v5.x (as that's what they are using
currently).
I'm keen to apply these and they look great, but honestly I've been
hesitant as they are significant and with larger patches there always is
some degree of risk, no matter how cautious we are.
To better address these needs, I will bump the minor version of releases
more regularly than what we've seen in the past; this doesn't reflect a
change of pace of the project, nor should you expect significant features
to be highlighted in each minor release: it just puts us in a position to
more reliably be able to ship important fixes in older releases, w/o such
release having to include also the many fast paced changes required by the
Reactive team.
I'm confident this makes sense to all: after all that's what the
minor/micro differences are for.
So nothing is really different here, expect that you'll likely see minor
releases happening more frequently from now on.
Thanks,
Sanne
3 years, 2 months
Re: HHH-14736 review and feedback requested
by Jason Pyeron
I have pushed some updates on HHH-14736 to https://github.com/pdinc-oss/hibernate-orm/tree/HHH-14736 - please provide feedback.
It needs more tests, but the crux of the change is as follows:
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/SourceType.java b/hibernate-core/src/main/java/org/hibernate/annotations/SourceType.java
index cfd0c153c7..0277ed1ef0 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/SourceType.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/SourceType.java
@@ -17,6 +17,16 @@ public enum SourceType {
*/
VM( "timestamp" ),
+ /**
+ * Get the binary, non-timestamp from the database.
+ */
+ DBBINARY( "dbbinary" ),
+
+ /**
+ * Get the binary, non-timestamp from the database, as a {@link Long}.
+ */
+ DBLONG( "dblong" ),
+
/**
* Get the timestamp from the database.
*/
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java
index 344b1e234c..971b948256 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java
@@ -782,6 +782,7 @@ public final class AnnotationBinder {
// check properties
final InheritanceState.ElementsToProcess elementsToProcess = inheritanceState.getElementsToProcess();
inheritanceState.postProcess( persistentClass, entityBinder );
+ context.getMetadataCollector().getDatabase().getDialect().getVersionColumnSupport().filter( elementsToProcess );
final boolean subclassAndSingleTableStrategy = inheritanceState.getType() == InheritanceType.SINGLE_TABLE
&& inheritanceState.hasParents();
diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java
index d157f8c599..0244ee4259 100644
--- a/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java
+++ b/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java
@@ -60,6 +60,8 @@ import org.hibernate.dialect.pagination.LegacyLimitHandler;
import org.hibernate.dialect.pagination.LimitHandler;
import org.hibernate.dialect.unique.DefaultUniqueDelegate;
import org.hibernate.dialect.unique.UniqueDelegate;
+import org.hibernate.dialect.version.DefaultNoOpVersionColumnSupportImpl;
+import org.hibernate.dialect.version.VersionColumnSupport;
import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.engine.config.spi.StandardConverters;
import org.hibernate.engine.jdbc.LobCreator;
@@ -1011,6 +1013,19 @@ public abstract class Dialect implements ConversionContext {
}
}
+ // VERSION support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ protected VersionColumnSupport versionSupport = new DefaultNoOpVersionColumnSupportImpl();
+
+ /**
+ * Get the appropriate {@link VersionColumnSupport}
+ *
+ * @return the {@link VersionColumnSupport}
+ * @since 5.1
+ */
+ public VersionColumnSupport getVersionColumnSupport() {
+ return versionSupport;
+ }
// GUID support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Then the magic happens inside the filter
1st it checks if it is an @Version property and that the rules for mapping Long to rowversion are in place
public void filter(ElementsToProcess elementsToProcess) {
if ( elementsToProcess == null )
return;
List<PropertyData> elements = elementsToProcess.getElements();
if ( elements == null || elements.isEmpty() )
return;
for ( int i = 0; i < elements.size(); ++i ) {
PropertyData element = elements.get( i );
if ( element == null )
continue;
XProperty prop = element.getProperty();
if ( prop == null )
continue;
if ( prop.getAnnotation( Version.class ) != null ) {
SQLServerNativeVersionAsLongOverride override = prop.getAnnotation( SQLServerNativeVersionAsLongOverride.class );
if ( prop.getType().getName().equals( Long.class.getName() ) ) {
if ( ( override == null && sqlServerDialect.isNativeVersionAsLong() ) || override.value() ) {
elements.set( i, new FilteredSQLServerLongVersionPropertyData( sqlServerDialect, sqlTypeRowversion, element ) );
}
}
else if ( prop.getType().getName().equals( byte[].class.getName() ) ) {
elements.set( i, new FilteredSQLServerByteArrayVersionPropertyData( sqlServerDialect, sqlTypeRowversion, element ) );
}
}
}
}
2nd (only showing the Long, there is one for byte[] too) then it on the fly filters the PropertyData to add the required non-default values and Hibernate specific configurations to the property
public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
// called from ColumnsBuilder:extractMetadata():76
T res = property.getAnnotation( annotationType );
if ( annotationType == null )
return res;
else if ( annotationType.isAssignableFrom( ColumnTransformer.class ) )
return (T) new FilteredSQLServerColumnTransformerAnnotation( sqlServerDialect, property,
(ColumnTransformer) ( res == null ? defaults.get( ColumnTransformer.class ) : res ) );
else if ( annotationType.isAssignableFrom( Generated.class ) )
return (T) new FilteredSQLServerGeneratedAnnotation( property, (Generated) ( res == null ? defaults.get( Generated.class ) : res ) );
else if ( annotationType.isAssignableFrom( Column.class ) )
return (T) new FilteredSQLServerColumnAnnotation( sqlTypeRowversion, property,
(Column) ( res == null ? defaults.get( Column.class ) : res ) );
else if ( annotationType.isAssignableFrom( Source.class ) )
return (T) new FilteredSQLServerSourceAnnotation( property, SOURCE.value(), (Source) ( res == null ? defaults.get( Source.class ) : res ) );
else
return res;
}
Respectfully,
Jason Pyeron
From: Jason Pyeron [mailto:jpyeron@pdinc.us]
Sent: Sunday, August 1, 2021 11:48 AM
To: 'Hibernate Dev' <hibernate-dev(a)lists.jboss.org>
Subject: HHH-14736 advice needed - metamodel updates by Dialect
I am new to the meta model internals of Hibernate, please bear with me.
I am working in processElementAnnotations to use the new VersionColumnSupport to add Dialect based defaults to the meta model – but I seem to be looking at this wrong.
Is there a test case, commit, or other documentation I can review to review as an example?
Basically, if the Dialect says so (e.g. SQL Server @Version on Long) and the author of the Entity does not specify conflicting configuration
Add to the meta model:
@Source(value = SourceType.DBLONG)
@ColumnTransformer(read = "CAST(… as BIGINT)")
@Column(columnDefinition = "rowversion", nullable = false, insertable = false, updatable = false)
@Generated(GenerationTime.ALWAYS)
I was updating the Column in the SimpleValue, but that did not get reflected in the runtime behavior – it only helped with schema generation.
commit 682fcbab75b8b055c676c7a4de1247a888b23e9c (HEAD -> HHH-14736, pdinc-oss/HHH-14736) - https://github.com/pdinc-oss/hibernate-orm/tree/HHH-14736
Author: Jason Pyeron <jpyeron(a)pdinc.us <mailto:jpyeron@pdinc.us> >
Date: Tue Jul 20 00:56:38 2021 -0400
HHH-14736 WIP: SQL Server @Version test cases (fails as expected)
* SQL Server 2016 dialect defaults to the new behavior, older version require it to be turned on
* added VersionColumnSupport to Dialect
* added SQLServerLongRowVersionType / SQLServerBinaryRowVersionType (was: SQLServerRowVersionType)
* when non-JPA annotations are allied, all tests pass
TODO:
1: update meta model to imply @ColumnTransformer(read = "CAST(...columnName... as BIGINT)")
2: update meta model to imply @Column(columnDefinition = "rowversion"), the create SQL already works
3: update meta model to imply @Column(nullable = false)
4: update meta model to imply @Column(insertable = false, updatable = false)
5: update meta model to imply @Generated(GenerationTime.ALWAYS)
6: need test case for setting SQLServer2012 dialect to use new features
7: address HqlSqlWalker.isDatabaseGeneratedTimestamp() - needs test case and possible code
M hibernate-core/src/main/java/org/hibernate/annotations/SourceType.java
M hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java
M hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java
M hibernate-core/src/main/java/org/hibernate/dialect/SQLServer2005Dialect.java
M hibernate-core/src/main/java/org/hibernate/dialect/SQLServer2016Dialect.java
M hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java
A hibernate-core/src/main/java/org/hibernate/dialect/version/DefaultNoOpVersionColumnSupportImpl.java
A hibernate-core/src/main/java/org/hibernate/dialect/version/SQLServerVersionColumnSupport.java
A hibernate-core/src/main/java/org/hibernate/dialect/version/VersionColumnSupport.java
M hibernate-core/src/main/java/org/hibernate/hql/internal/ast/HqlSqlWalker.java
M hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataContext.java
M hibernate-core/src/main/java/org/hibernate/type/BasicTypeRegistry.java
M hibernate-core/src/main/java/org/hibernate/type/RowVersionType.java
A hibernate-core/src/main/java/org/hibernate/type/SQLServerBinaryRowVersionType.java
A hibernate-core/src/main/java/org/hibernate/type/SQLServerLongRowVersionType.java
M hibernate-core/src/test/java/org/hibernate/test/annotations/various/TimestampTest.java
A hibernate-core/src/test/java/org/hibernate/test/optlock/OptimisticLockHHH14736SQLServerJPAOnlyTest.java
A hibernate-core/src/test/java/org/hibernate/test/optlock/OptimisticLockHHH14736Test.java
-Jason
--
Jason Pyeron | Architect
Contractor |
PD Inc | Certified SBA 8(a)
10 w 24th St | Certified SBA HUBZone
Baltimore, MD | CAGE Code: 1WVR6
.com: jpyeron(a)pdinc.us <mailto:jpyeron@pdinc.us>
tel : 202-741-9397
3 years, 3 months
JDK 17 is now in the Release Candidate Phase
by Rory O'Donnell
Hi Sanne & Yoann,
*Per the JDK 17 schedule , we are now in the Release Candidate Phase
[1][2].*
*
*
*Please advise if you find any issues while testing the latest Early
Access builds.*
* Schedule:
o *2021/08/05 Initial Release Candidate *
o 2021/08/19 Final Release Candidate
o 2021/09/14 General Availability
The overall feature set is frozen. No further JEPs will be targeted to
this release.
* Features integrated in JDK 17:
o JEP 306: Restore Always-Strict Floating-Point Semantics
<https://openjdk.java.net/jeps/306>
o JEP 356: Enhanced Pseudo-Random Number Generators
<https://openjdk.java.net/jeps/356>
o JEP 382: New macOS Rendering Pipeline
<https://openjdk.java.net/jeps/382>
o JEP 391: macOS/AArch64 Port <https://openjdk.java.net/jeps/391>
o JEP 398: Deprecate the Applet API for Removal
<https://openjdk.java.net/jeps/398>
o JEP 403: Strongly Encapsulate JDK Internals
<https://openjdk.java.net/jeps/403>
o JEP 406: Pattern Matching for switch (Preview)
<https://openjdk.java.net/jeps/406>
o JEP 407: Remove RMI Activation <https://openjdk.java.net/jeps/407>
o JEP 409: Sealed Classes <https://openjdk.java.net/jeps/409>
o JEP 410: Remove the Experimental AOT and JIT Compiler
<https://openjdk.java.net/jeps/410>
o JEP 411: Deprecate the Security Manager for Removal
<https://openjdk.java.net/jeps/411>
o JEP 412: Foreign Function & Memory API (Incubator)
<https://openjdk.java.net/jeps/412>
o JEP 414: Vector API (Second Incubator)
<https://openjdk.java.net/jeps/414>
o JEP 415: Context-Specific Deserialization Filters
<https://openjdk.java.net/jeps/415>
*
*
*OpenJDK 17 Early Accessbuild 35 is available at
**https://jdk.java.net/17* <https://jdk.java.net/17>
* These early-access , open-source builds are provided under the
o GNU General Public License, version 2, with the Classpath
Exception <https://openjdk.java.net/legal/gplv2+ce.html>
* Release Notes are available at https://jdk.java.net/17/release-notes
<https://jdk.java.net/17/release-notes>
* Changes in recent builds that maybe of interest:
o JDK-8270866: NPE in DocTreePath.getTreePath()[build 33]
+ Reportedby jOOQ
**Topics of Interest: *
*
* The latest Newscast covers 17's JEP 356
<https://openjdk.java.net/jeps/356>: Enhanced Pseudo-Random Number
Generators - Here
<https://inside.java/2021/07/29/insidejava-newscast-009/>
* The latest JEP Café cover 17's JEP 409
<https://openjdk.java.net/jeps/409> : Sealed Classes - Here
<https://inside.java/2021/07/22/jepcafe2/>
* A few updates to JEP 411 <https://openjdk.java.net/jeps/411>:
Deprecate the Security Manager for Removal - Here
<https://mail.openjdk.java.net/pipermail/security-dev/2021-July/026806.html>
*
*
*OpenJDK**18 Early Access build 9 is available at
**https://jdk.java.net/18* <https://jdk.java.net/18>
* These early-access , open-source builds are provided under the
o GNU General Public License, version 2, with the Classpath
Exception <https://openjdk.java.net/legal/gplv2+ce.html>
* Release Notes are available at https://jdk.java.net/18/release-notes
<https://jdk.java.net/18/release-notes>
* Changes in recent builds that maybe of interest:
o JDK-8225082: Remove IdenTrust certificate that is expiring in
September 2021 [build 9]
o JDK-8251329: Zip File System Provider Throws ZipException when
entry name element contains "." or ".." [build 9]
o JDK-8271359: NPE in DocTreePath.getTreePath() [build 8]
+ Reported by jOOQ
*July 2021 Critical Patch Update Released*
* As part of the July 2021, we released JDK 16.0.2, JDK 11.0.12 LTS,
JDK 8u301 and JDK 7u311 as well as OpenJDK 16.0.2 (publicly available)
Rgds,Rory
[1] https://mail.openjdk.java.net/pipermail/jdk-dev/2021-August/005894.html
[2] https://mail.openjdk.java.net/pipermail/jdk-dev/2021-August/005906.html
--
Rgds, Rory O'Donnell
Quality Engineering Manager
Oracle EMEA, Dublin, Ireland
3 years, 3 months
HHH-14736 advice needed - metamodel updates by Dialect
by Jason Pyeron
I am new to the meta model internals of Hibernate, please bear with me.
I am working in processElementAnnotations to use the new VersionColumnSupport to add Dialect based defaults to the meta model – but I seem to be looking at this wrong.
Is there a test case, commit, or other documentation I can review to review as an example?
Basically, if the Dialect says so (e.g. SQL Server @Version on Long) and the author of the Entity does not specify conflicting configuration
Add to the meta model:
@Source(value = SourceType.DBLONG)
@ColumnTransformer(read = "CAST(… as BIGINT)")
@Column(columnDefinition = "rowversion", nullable = false, insertable = false, updatable = false)
@Generated(GenerationTime.ALWAYS)
I was updating the Column in the SimpleValue, but that did not get reflected in the runtime behavior – it only helped with schema generation.
commit 682fcbab75b8b055c676c7a4de1247a888b23e9c (HEAD -> HHH-14736, pdinc-oss/HHH-14736) - https://github.com/pdinc-oss/hibernate-orm/tree/HHH-14736
Author: Jason Pyeron <jpyeron(a)pdinc.us>
Date: Tue Jul 20 00:56:38 2021 -0400
HHH-14736 WIP: SQL Server @Version test cases (fails as expected)
* SQL Server 2016 dialect defaults to the new behavior, older version require it to be turned on
* added VersionColumnSupport to Dialect
* added SQLServerLongRowVersionType / SQLServerBinaryRowVersionType (was: SQLServerRowVersionType)
* when non-JPA annotations are allied, all tests pass
TODO:
1: update meta model to imply @ColumnTransformer(read = "CAST(...columnName... as BIGINT)")
2: update meta model to imply @Column(columnDefinition = "rowversion"), the create SQL already works
3: update meta model to imply @Column(nullable = false)
4: update meta model to imply @Column(insertable = false, updatable = false)
5: update meta model to imply @Generated(GenerationTime.ALWAYS)
6: need test case for setting SQLServer2012 dialect to use new features
7: address HqlSqlWalker.isDatabaseGeneratedTimestamp() - needs test case and possible code
M hibernate-core/src/main/java/org/hibernate/annotations/SourceType.java
M hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java
M hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java
M hibernate-core/src/main/java/org/hibernate/dialect/SQLServer2005Dialect.java
M hibernate-core/src/main/java/org/hibernate/dialect/SQLServer2016Dialect.java
M hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java
A hibernate-core/src/main/java/org/hibernate/dialect/version/DefaultNoOpVersionColumnSupportImpl.java
A hibernate-core/src/main/java/org/hibernate/dialect/version/SQLServerVersionColumnSupport.java
A hibernate-core/src/main/java/org/hibernate/dialect/version/VersionColumnSupport.java
M hibernate-core/src/main/java/org/hibernate/hql/internal/ast/HqlSqlWalker.java
M hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataContext.java
M hibernate-core/src/main/java/org/hibernate/type/BasicTypeRegistry.java
M hibernate-core/src/main/java/org/hibernate/type/RowVersionType.java
A hibernate-core/src/main/java/org/hibernate/type/SQLServerBinaryRowVersionType.java
A hibernate-core/src/main/java/org/hibernate/type/SQLServerLongRowVersionType.java
M hibernate-core/src/test/java/org/hibernate/test/annotations/various/TimestampTest.java
A hibernate-core/src/test/java/org/hibernate/test/optlock/OptimisticLockHHH14736SQLServerJPAOnlyTest.java
A hibernate-core/src/test/java/org/hibernate/test/optlock/OptimisticLockHHH14736Test.java
-Jason
--
Jason Pyeron | Architect
Contractor |
PD Inc | Certified SBA 8(a)
10 w 24th St | Certified SBA HUBZone
Baltimore, MD | CAGE Code: 1WVR6
.com: <mailto:jpyeron@pdinc.us> jpyeron(a)pdinc.us
tel : 202-741-9397
3 years, 3 months