SlideShare a Scribd company logo
1 of 26
Download to read offline
What’s new in Hibernate 6.0?
by Christian Beikov
Who am I?
Christian Beikov
Long time Hibernate community contributor
Full time Hibernate developer at Red Hat since 2020
Founder of Blazebit and creator of Blaze-Persistence
Living in Vienna/AT and Bonn/DE
Like to play tennis and go running
Motivation for Hibernate 6.0
Performance improvements
● Read by name is slow in JDBC ResultSet
● JPA Criteria implementation required string building and parsing
Design improvements
● Query AST was Antlr2 based and hard to maintain/extend
● Dialect specific SQL translation was hard
● Runtime model was centered around Type
● Cleanup of deprecated APIs and SPIs
● More type safety and generics improvements
Read by name
Changing to position based ResultSetreading has big impact
● Throughput testing showed it is faster
● Many APIs and SPIs needed to adapt e.g. Type
● Allows omitting select aliases and produce smaller SQL
Took the opportunity to implement select item deduplication
● Occasionally requested enhancement
● Reduce amount of fetched data
Read by name
Hibernate 5.x
select
entity0_.id as id1_1_0_,
entity0_.name as name2_1_0_,
entity0_.id as onetoone3_1_0_
from
Entity entity0_
where
entity0_.id=?
Hibernate 6.0
select
e1_0.id,
e1_0.name
from
Entity e1_0
where
e1_0.id=?
JPA Criteria
5.x handles JPA Criteria on top of HQL
● CriteriaQueryis translated to HQL and then parsed
● But uses a special CriteriaLoaderwith custom fetch handling
6.0 introduces the semantic query model (SQM) as AST model
● SQM AST implements JPA Criteria API
● HQL is also parsed to SQM AST
● Further boost with hibernate.criteria.copy_treedisabled
● Smart handling of plain values parameter vs. literal
Query improvements
Semantic query model (SQM) as unified AST for JPA Criteria and HQL
Easier maintenance/extensibility thanks to update to ANTLR4
Functions received lots of new features
● FunctionReturnTypeResolverwith full AST access e.g. extract(second)
● FunctionArgumentTypeResolverinference through context e.g. coalesce(..)
● ArgumentsValidatorfor early type validation
● Can generate special SQM- and SQL-AST for e.g. emulations
Query improvements
Set operation support (from ANSI SQL-92)
select e from Entity e where e.type = 1
union
select e from Entity e where e.type = 2
intersect
select e from Entity e where e.type = 3
except
select e from Entity e where e.deleted
Query improvements
Set operation support in JPA Criteria
HibernateCriteriaBuilder cb = session.getCriteriaBuilder();
var q1 = cb.createQuery( Entity.class );
var q2 = cb.createQuery( Entity.class );
// Apply restrictions to q1 and q2 ...
TypedQuery<Entity> q = session.createQuery( cb.union( q1, q2 ) );
Query improvements
LIMIT, OFFSETand FETCHclause support (ANSI SQL 2003)
select p.name, p.score
from Player p
order by p.score desc
fetch first 3 rows with ties
name score
Thor 10
Hulk 10
Tony 7
Vision 7
Query improvements
LIMIT, OFFSETand FETCHclause support
HibernateCriteriaBuilder cb = session.getCriteriaBuilder();
JpaCriteriaQuery<Entity> q1 = cb.createQuery( Entity.class );
JpaRoot<Entity> root = q1.from( Entity.class );
q1.fetch( 3, FetchClauseType.ROWS_WITH_TIES );
TypedQuery<Entity> q = session.createQuery( q1 );
Query improvements
Support for OVERclause a.k.a. window functions (ANSI SQL 2003)
select
format(c.ts as ‘yyyy’’Q’’Q’),
sum(c.amount),
sum(c.amount) - lag(sum(c.amount))
over (order by format(c.ts as ‘yyyy’’Q’’Q’)) as delta
from Costs c
group by format(c.ts as ‘yyyy’’Q’’Q’)
period amount delta
2021Q4 100 NULL
2022Q1 120 20
Query improvements
Ordered set-aggregate functions i.e. LISTAGG(ANSI SQL 2016)
select pr.id, listagg(p.name, ‘, ’) within group (order by p.name)
from Project pr join pr.participants p
group by pr.id
order by pr.id
id participants
1 Bruce Banner, Natasha Romanoff, Tony Stark
.. ..
Query improvements
Summarization support i.e. ROLLUP(ANSI SQL-99)
select
s.state,
s.city,
sum(s.price * s.quantity)
from Sales s
group by rollup (s.state, s.city)
order by s.state, s.city nulls last
state city amount
CA SF 100
CA SJ 120
CA NULL 220
Query improvements
FILTER clause support (ANSI SQL 2016)
select
count(*) filter (where s.price * s.quantity < 10) as small_sales,
count(*) filter (where s.price * s.quantity >= 10) as big_sales
from Sales s
small_sales big_sales
10 20
Query improvements
ILIKEpredicate support
select e
from Entity e
where e.name ilike ‘%tony%’
Fallback to lower(e.name) like lower(‘%tony’)
Query improvements
Tuple syntax support with great emulation
Align expressions/predicates i.e. ... where my_function(value > 1) and ...
Temporal arithmetic support i.e. ts1 - ts2returns Duration
Duration extraction support with BY operator i.e. (ts1 - ts2) by hour
Duration literal support i.e. ts1 + 1 day
Support for DISTINCT FROMpredicate
etc.
Query improvements
Session#createSelectionQueryfor select only queries
● No executeUpdatemethod
Session#createMutationQueryfor mutation only queries
● No getResultList/getSingleResultetc. methods
Early validations and communication of intent
Dialect specific SQL
SQL-AST as intermediate representation of (modern) SQL as tree
5.x has a single HQL to SQL string translator with lots of if-branches per dialect-support
Dialects in 6.0 provide custom translators for handling emulations
SQL-AST enables sophisticated transformations/emulations efficiently
● Introduction of dummy FROMelements (Sybase)
● Emulate aggregate functions through window functions (MySQL, SQL Server, …)
Runtime model
Model in 5.x was centered around org.hibernate.type.Type
Created OO runtime model since switch to read by position required changes anyway
Moved logic to runtime model defined through capabilities i.e. Fetchable
Removed multi-column basic mappings in favor of custom embeddable mappings
Split logic from BasicTypeinto JdbcType/JavaTypeand removed most implementations
Introduce BasicTypeReferencein StandardBasicTypesfor late resolving
Support for new SQL types through Dialect contribution
● JSONtype for storing any type as JSONB/JSON/CLOB/VARCHAR
● UUIDtype for java.util.UUID
● INTERVAL_SECONDtype for java.time.Duration
● INETtype for java.net.InetAddress
Replace @TypeDefwith type safe variants i.e. @JavaTypeRegistration
Replace @Typewith type safe variants i.e. @JavaType
Mapping improvements
Mapping improvements
CompositeUserTypebridges gap between custom types and embeddables
Embeddable mapper class for defining mapping structure
Full control on construction and deconstruction of custom type
● Support for library types i.e. MonetaryAmount
● Repurpose existing types i.e. OffsetDateTime
Out of the box support for Java records in discussion
Demo time
https://github.com/beikov/presentation-hibernate-6
Other changes
Switch to Jakarta Persistence
Remove deprecated stuff i.e. legacy Criteria API
Add type variables to APIs/SPIs where possible
Dialectwas majorly updated
Renaming of JavaTypeDescriptorand SqlTypeDescriptor
See https://github.com/hibernate/hibernate-orm/blob/main/migration-guide.adoc
What’s next?
Subqueries in the from clause
Common table expressions
Lateral joins
Insert-or-Update a.k.a. Upsert
Table functions
SQL structs
SQL arrays
Q & A

More Related Content

What's hot

Dx11 performancereloaded
Dx11 performancereloadedDx11 performancereloaded
Dx11 performancereloadedmistercteam
 
#10 pydata warsaw object detection with dn ns
#10   pydata warsaw object detection with dn ns#10   pydata warsaw object detection with dn ns
#10 pydata warsaw object detection with dn nsAndrew Brozek
 
Introduction to GCP
Introduction to GCPIntroduction to GCP
Introduction to GCPKnoldus Inc.
 
Evolution of the StyleGAN family
Evolution of the StyleGAN familyEvolution of the StyleGAN family
Evolution of the StyleGAN familyVitaly Bondar
 
LLaMA Open and Efficient Foundation Language Models - 230528.pdf
LLaMA Open and Efficient Foundation Language Models - 230528.pdfLLaMA Open and Efficient Foundation Language Models - 230528.pdf
LLaMA Open and Efficient Foundation Language Models - 230528.pdftaeseon ryu
 
Camel Day Italia 2021 - Camel K
Camel Day Italia 2021 - Camel KCamel Day Italia 2021 - Camel K
Camel Day Italia 2021 - Camel KNicola Ferraro
 
AI - Last Year Progress (2018-2019)
AI - Last Year Progress (2018-2019)AI - Last Year Progress (2018-2019)
AI - Last Year Progress (2018-2019)Grigory Sapunov
 
Cassandra at Instagram 2016 (Dikang Gu, Facebook) | Cassandra Summit 2016
Cassandra at Instagram 2016 (Dikang Gu, Facebook) | Cassandra Summit 2016Cassandra at Instagram 2016 (Dikang Gu, Facebook) | Cassandra Summit 2016
Cassandra at Instagram 2016 (Dikang Gu, Facebook) | Cassandra Summit 2016DataStax
 
You only look once (YOLO) : unified real time object detection
You only look once (YOLO) : unified real time object detectionYou only look once (YOLO) : unified real time object detection
You only look once (YOLO) : unified real time object detectionEntrepreneur / Startup
 
Modeling uncertainty in deep learning
Modeling uncertainty in deep learning Modeling uncertainty in deep learning
Modeling uncertainty in deep learning Sungjoon Choi
 
GS-4150, Bullet 3 OpenCL Rigid Body Simulation, by Erwin Coumans
GS-4150, Bullet 3 OpenCL Rigid Body Simulation, by Erwin CoumansGS-4150, Bullet 3 OpenCL Rigid Body Simulation, by Erwin Coumans
GS-4150, Bullet 3 OpenCL Rigid Body Simulation, by Erwin CoumansAMD Developer Central
 
End-to-end Speech Recognition with Recurrent Neural Networks (D3L6 Deep Learn...
End-to-end Speech Recognition with Recurrent Neural Networks (D3L6 Deep Learn...End-to-end Speech Recognition with Recurrent Neural Networks (D3L6 Deep Learn...
End-to-end Speech Recognition with Recurrent Neural Networks (D3L6 Deep Learn...Universitat Politècnica de Catalunya
 
Test strategies for data processing pipelines
Test strategies for data processing pipelinesTest strategies for data processing pipelines
Test strategies for data processing pipelinesLars Albertsson
 
Peeking inside the engine of ZIO SQL.pdf
Peeking inside the engine of ZIO SQL.pdfPeeking inside the engine of ZIO SQL.pdf
Peeking inside the engine of ZIO SQL.pdfJaroslavRegec1
 
Serverless integration with Knative and Apache Camel on Kubernetes
Serverless integration with Knative and Apache Camel on KubernetesServerless integration with Knative and Apache Camel on Kubernetes
Serverless integration with Knative and Apache Camel on KubernetesClaus Ibsen
 
Introducing BinarySortedMultiMap - A new Flink state primitive to boost your ...
Introducing BinarySortedMultiMap - A new Flink state primitive to boost your ...Introducing BinarySortedMultiMap - A new Flink state primitive to boost your ...
Introducing BinarySortedMultiMap - A new Flink state primitive to boost your ...Flink Forward
 

What's hot (20)

Dx11 performancereloaded
Dx11 performancereloadedDx11 performancereloaded
Dx11 performancereloaded
 
#10 pydata warsaw object detection with dn ns
#10   pydata warsaw object detection with dn ns#10   pydata warsaw object detection with dn ns
#10 pydata warsaw object detection with dn ns
 
Yolov3
Yolov3Yolov3
Yolov3
 
Introduction to GCP
Introduction to GCPIntroduction to GCP
Introduction to GCP
 
Evolution of the StyleGAN family
Evolution of the StyleGAN familyEvolution of the StyleGAN family
Evolution of the StyleGAN family
 
LLaMA Open and Efficient Foundation Language Models - 230528.pdf
LLaMA Open and Efficient Foundation Language Models - 230528.pdfLLaMA Open and Efficient Foundation Language Models - 230528.pdf
LLaMA Open and Efficient Foundation Language Models - 230528.pdf
 
Camel Day Italia 2021 - Camel K
Camel Day Italia 2021 - Camel KCamel Day Italia 2021 - Camel K
Camel Day Italia 2021 - Camel K
 
Global illumination
Global illuminationGlobal illumination
Global illumination
 
AI - Last Year Progress (2018-2019)
AI - Last Year Progress (2018-2019)AI - Last Year Progress (2018-2019)
AI - Last Year Progress (2018-2019)
 
Cassandra at Instagram 2016 (Dikang Gu, Facebook) | Cassandra Summit 2016
Cassandra at Instagram 2016 (Dikang Gu, Facebook) | Cassandra Summit 2016Cassandra at Instagram 2016 (Dikang Gu, Facebook) | Cassandra Summit 2016
Cassandra at Instagram 2016 (Dikang Gu, Facebook) | Cassandra Summit 2016
 
You only look once (YOLO) : unified real time object detection
You only look once (YOLO) : unified real time object detectionYou only look once (YOLO) : unified real time object detection
You only look once (YOLO) : unified real time object detection
 
Modeling uncertainty in deep learning
Modeling uncertainty in deep learning Modeling uncertainty in deep learning
Modeling uncertainty in deep learning
 
Style gan
Style ganStyle gan
Style gan
 
GS-4150, Bullet 3 OpenCL Rigid Body Simulation, by Erwin Coumans
GS-4150, Bullet 3 OpenCL Rigid Body Simulation, by Erwin CoumansGS-4150, Bullet 3 OpenCL Rigid Body Simulation, by Erwin Coumans
GS-4150, Bullet 3 OpenCL Rigid Body Simulation, by Erwin Coumans
 
End-to-end Speech Recognition with Recurrent Neural Networks (D3L6 Deep Learn...
End-to-end Speech Recognition with Recurrent Neural Networks (D3L6 Deep Learn...End-to-end Speech Recognition with Recurrent Neural Networks (D3L6 Deep Learn...
End-to-end Speech Recognition with Recurrent Neural Networks (D3L6 Deep Learn...
 
Test strategies for data processing pipelines
Test strategies for data processing pipelinesTest strategies for data processing pipelines
Test strategies for data processing pipelines
 
Peeking inside the engine of ZIO SQL.pdf
Peeking inside the engine of ZIO SQL.pdfPeeking inside the engine of ZIO SQL.pdf
Peeking inside the engine of ZIO SQL.pdf
 
Real time data quality on Flink
Real time data quality on FlinkReal time data quality on Flink
Real time data quality on Flink
 
Serverless integration with Knative and Apache Camel on Kubernetes
Serverless integration with Knative and Apache Camel on KubernetesServerless integration with Knative and Apache Camel on Kubernetes
Serverless integration with Knative and Apache Camel on Kubernetes
 
Introducing BinarySortedMultiMap - A new Flink state primitive to boost your ...
Introducing BinarySortedMultiMap - A new Flink state primitive to boost your ...Introducing BinarySortedMultiMap - A new Flink state primitive to boost your ...
Introducing BinarySortedMultiMap - A new Flink state primitive to boost your ...
 

Similar to Hibernate 6.0 - What's new.pdf

Spring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard WolffSpring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard WolffJAX London
 
SQL Server 2000 Research Series - Transact SQL
SQL Server 2000 Research Series - Transact SQLSQL Server 2000 Research Series - Transact SQL
SQL Server 2000 Research Series - Transact SQLJerry Yang
 
PostgreSQL 8.4 TriLUG 2009-11-12
PostgreSQL 8.4 TriLUG 2009-11-12PostgreSQL 8.4 TriLUG 2009-11-12
PostgreSQL 8.4 TriLUG 2009-11-12Andrew Dunstan
 
Slice: OpenJPA for Distributed Persistence
Slice: OpenJPA for Distributed PersistenceSlice: OpenJPA for Distributed Persistence
Slice: OpenJPA for Distributed PersistencePinaki Poddar
 
Core2 Document - Java SCORE Overview.pptx.pdf
Core2 Document - Java SCORE Overview.pptx.pdfCore2 Document - Java SCORE Overview.pptx.pdf
Core2 Document - Java SCORE Overview.pptx.pdfThchTrngGia
 
Java New Evolution
Java New EvolutionJava New Evolution
Java New EvolutionAllan Huang
 
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1MariaDB plc
 
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1MariaDB plc
 
Apache Calcite: One Frontend to Rule Them All
Apache Calcite: One Frontend to Rule Them AllApache Calcite: One Frontend to Rule Them All
Apache Calcite: One Frontend to Rule Them AllMichael Mior
 
What’s New in MariaDB Server 10.2
What’s New in MariaDB Server 10.2What’s New in MariaDB Server 10.2
What’s New in MariaDB Server 10.2MariaDB plc
 
Die Neuheiten in MariaDB 10.2 und MaxScale 2.1
Die Neuheiten in MariaDB 10.2 und MaxScale 2.1Die Neuheiten in MariaDB 10.2 und MaxScale 2.1
Die Neuheiten in MariaDB 10.2 und MaxScale 2.1MariaDB plc
 
Java one 2010
Java one 2010Java one 2010
Java one 2010scdn
 
NOSQL and Cassandra
NOSQL and CassandraNOSQL and Cassandra
NOSQL and Cassandrarantav
 
WSO2 Product Release Webinar: WSO2 Complex Event Processor 4.0
WSO2 Product Release Webinar: WSO2 Complex Event Processor 4.0WSO2 Product Release Webinar: WSO2 Complex Event Processor 4.0
WSO2 Product Release Webinar: WSO2 Complex Event Processor 4.0WSO2
 
Meetup cassandra for_java_cql
Meetup cassandra for_java_cqlMeetup cassandra for_java_cql
Meetup cassandra for_java_cqlzznate
 
Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...
Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...
Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...Databricks
 
03 2017Emea_RoadshowMilan-WhatsNew-Mariadbserver10_2andmaxscale 2_1
03 2017Emea_RoadshowMilan-WhatsNew-Mariadbserver10_2andmaxscale 2_103 2017Emea_RoadshowMilan-WhatsNew-Mariadbserver10_2andmaxscale 2_1
03 2017Emea_RoadshowMilan-WhatsNew-Mariadbserver10_2andmaxscale 2_1mlraviol
 
Javatraining
JavatrainingJavatraining
Javatrainingducat1989
 

Similar to Hibernate 6.0 - What's new.pdf (20)

Spring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard WolffSpring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard Wolff
 
Scala and Spring
Scala and SpringScala and Spring
Scala and Spring
 
SQL Server 2000 Research Series - Transact SQL
SQL Server 2000 Research Series - Transact SQLSQL Server 2000 Research Series - Transact SQL
SQL Server 2000 Research Series - Transact SQL
 
PostgreSQL 8.4 TriLUG 2009-11-12
PostgreSQL 8.4 TriLUG 2009-11-12PostgreSQL 8.4 TriLUG 2009-11-12
PostgreSQL 8.4 TriLUG 2009-11-12
 
Slice: OpenJPA for Distributed Persistence
Slice: OpenJPA for Distributed PersistenceSlice: OpenJPA for Distributed Persistence
Slice: OpenJPA for Distributed Persistence
 
Core2 Document - Java SCORE Overview.pptx.pdf
Core2 Document - Java SCORE Overview.pptx.pdfCore2 Document - Java SCORE Overview.pptx.pdf
Core2 Document - Java SCORE Overview.pptx.pdf
 
Java New Evolution
Java New EvolutionJava New Evolution
Java New Evolution
 
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
 
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
 
Apache Calcite: One Frontend to Rule Them All
Apache Calcite: One Frontend to Rule Them AllApache Calcite: One Frontend to Rule Them All
Apache Calcite: One Frontend to Rule Them All
 
What’s New in MariaDB Server 10.2
What’s New in MariaDB Server 10.2What’s New in MariaDB Server 10.2
What’s New in MariaDB Server 10.2
 
Die Neuheiten in MariaDB 10.2 und MaxScale 2.1
Die Neuheiten in MariaDB 10.2 und MaxScale 2.1Die Neuheiten in MariaDB 10.2 und MaxScale 2.1
Die Neuheiten in MariaDB 10.2 und MaxScale 2.1
 
Java one 2010
Java one 2010Java one 2010
Java one 2010
 
NOSQL and Cassandra
NOSQL and CassandraNOSQL and Cassandra
NOSQL and Cassandra
 
WSO2 Product Release Webinar: WSO2 Complex Event Processor 4.0
WSO2 Product Release Webinar: WSO2 Complex Event Processor 4.0WSO2 Product Release Webinar: WSO2 Complex Event Processor 4.0
WSO2 Product Release Webinar: WSO2 Complex Event Processor 4.0
 
Meetup cassandra for_java_cql
Meetup cassandra for_java_cqlMeetup cassandra for_java_cql
Meetup cassandra for_java_cql
 
Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...
Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...
Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...
 
03 2017Emea_RoadshowMilan-WhatsNew-Mariadbserver10_2andmaxscale 2_1
03 2017Emea_RoadshowMilan-WhatsNew-Mariadbserver10_2andmaxscale 2_103 2017Emea_RoadshowMilan-WhatsNew-Mariadbserver10_2andmaxscale 2_1
03 2017Emea_RoadshowMilan-WhatsNew-Mariadbserver10_2andmaxscale 2_1
 
Javatraining
JavatrainingJavatraining
Javatraining
 
Ast transformation
Ast transformationAst transformation
Ast transformation
 

Recently uploaded

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 

Recently uploaded (20)

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 

Hibernate 6.0 - What's new.pdf

  • 1. What’s new in Hibernate 6.0? by Christian Beikov
  • 2. Who am I? Christian Beikov Long time Hibernate community contributor Full time Hibernate developer at Red Hat since 2020 Founder of Blazebit and creator of Blaze-Persistence Living in Vienna/AT and Bonn/DE Like to play tennis and go running
  • 3. Motivation for Hibernate 6.0 Performance improvements ● Read by name is slow in JDBC ResultSet ● JPA Criteria implementation required string building and parsing Design improvements ● Query AST was Antlr2 based and hard to maintain/extend ● Dialect specific SQL translation was hard ● Runtime model was centered around Type ● Cleanup of deprecated APIs and SPIs ● More type safety and generics improvements
  • 4. Read by name Changing to position based ResultSetreading has big impact ● Throughput testing showed it is faster ● Many APIs and SPIs needed to adapt e.g. Type ● Allows omitting select aliases and produce smaller SQL Took the opportunity to implement select item deduplication ● Occasionally requested enhancement ● Reduce amount of fetched data
  • 5. Read by name Hibernate 5.x select entity0_.id as id1_1_0_, entity0_.name as name2_1_0_, entity0_.id as onetoone3_1_0_ from Entity entity0_ where entity0_.id=? Hibernate 6.0 select e1_0.id, e1_0.name from Entity e1_0 where e1_0.id=?
  • 6. JPA Criteria 5.x handles JPA Criteria on top of HQL ● CriteriaQueryis translated to HQL and then parsed ● But uses a special CriteriaLoaderwith custom fetch handling 6.0 introduces the semantic query model (SQM) as AST model ● SQM AST implements JPA Criteria API ● HQL is also parsed to SQM AST ● Further boost with hibernate.criteria.copy_treedisabled ● Smart handling of plain values parameter vs. literal
  • 7. Query improvements Semantic query model (SQM) as unified AST for JPA Criteria and HQL Easier maintenance/extensibility thanks to update to ANTLR4 Functions received lots of new features ● FunctionReturnTypeResolverwith full AST access e.g. extract(second) ● FunctionArgumentTypeResolverinference through context e.g. coalesce(..) ● ArgumentsValidatorfor early type validation ● Can generate special SQM- and SQL-AST for e.g. emulations
  • 8. Query improvements Set operation support (from ANSI SQL-92) select e from Entity e where e.type = 1 union select e from Entity e where e.type = 2 intersect select e from Entity e where e.type = 3 except select e from Entity e where e.deleted
  • 9. Query improvements Set operation support in JPA Criteria HibernateCriteriaBuilder cb = session.getCriteriaBuilder(); var q1 = cb.createQuery( Entity.class ); var q2 = cb.createQuery( Entity.class ); // Apply restrictions to q1 and q2 ... TypedQuery<Entity> q = session.createQuery( cb.union( q1, q2 ) );
  • 10. Query improvements LIMIT, OFFSETand FETCHclause support (ANSI SQL 2003) select p.name, p.score from Player p order by p.score desc fetch first 3 rows with ties name score Thor 10 Hulk 10 Tony 7 Vision 7
  • 11. Query improvements LIMIT, OFFSETand FETCHclause support HibernateCriteriaBuilder cb = session.getCriteriaBuilder(); JpaCriteriaQuery<Entity> q1 = cb.createQuery( Entity.class ); JpaRoot<Entity> root = q1.from( Entity.class ); q1.fetch( 3, FetchClauseType.ROWS_WITH_TIES ); TypedQuery<Entity> q = session.createQuery( q1 );
  • 12. Query improvements Support for OVERclause a.k.a. window functions (ANSI SQL 2003) select format(c.ts as ‘yyyy’’Q’’Q’), sum(c.amount), sum(c.amount) - lag(sum(c.amount)) over (order by format(c.ts as ‘yyyy’’Q’’Q’)) as delta from Costs c group by format(c.ts as ‘yyyy’’Q’’Q’) period amount delta 2021Q4 100 NULL 2022Q1 120 20
  • 13. Query improvements Ordered set-aggregate functions i.e. LISTAGG(ANSI SQL 2016) select pr.id, listagg(p.name, ‘, ’) within group (order by p.name) from Project pr join pr.participants p group by pr.id order by pr.id id participants 1 Bruce Banner, Natasha Romanoff, Tony Stark .. ..
  • 14. Query improvements Summarization support i.e. ROLLUP(ANSI SQL-99) select s.state, s.city, sum(s.price * s.quantity) from Sales s group by rollup (s.state, s.city) order by s.state, s.city nulls last state city amount CA SF 100 CA SJ 120 CA NULL 220
  • 15. Query improvements FILTER clause support (ANSI SQL 2016) select count(*) filter (where s.price * s.quantity < 10) as small_sales, count(*) filter (where s.price * s.quantity >= 10) as big_sales from Sales s small_sales big_sales 10 20
  • 16. Query improvements ILIKEpredicate support select e from Entity e where e.name ilike ‘%tony%’ Fallback to lower(e.name) like lower(‘%tony’)
  • 17. Query improvements Tuple syntax support with great emulation Align expressions/predicates i.e. ... where my_function(value > 1) and ... Temporal arithmetic support i.e. ts1 - ts2returns Duration Duration extraction support with BY operator i.e. (ts1 - ts2) by hour Duration literal support i.e. ts1 + 1 day Support for DISTINCT FROMpredicate etc.
  • 18. Query improvements Session#createSelectionQueryfor select only queries ● No executeUpdatemethod Session#createMutationQueryfor mutation only queries ● No getResultList/getSingleResultetc. methods Early validations and communication of intent
  • 19. Dialect specific SQL SQL-AST as intermediate representation of (modern) SQL as tree 5.x has a single HQL to SQL string translator with lots of if-branches per dialect-support Dialects in 6.0 provide custom translators for handling emulations SQL-AST enables sophisticated transformations/emulations efficiently ● Introduction of dummy FROMelements (Sybase) ● Emulate aggregate functions through window functions (MySQL, SQL Server, …)
  • 20. Runtime model Model in 5.x was centered around org.hibernate.type.Type Created OO runtime model since switch to read by position required changes anyway Moved logic to runtime model defined through capabilities i.e. Fetchable Removed multi-column basic mappings in favor of custom embeddable mappings Split logic from BasicTypeinto JdbcType/JavaTypeand removed most implementations Introduce BasicTypeReferencein StandardBasicTypesfor late resolving
  • 21. Support for new SQL types through Dialect contribution ● JSONtype for storing any type as JSONB/JSON/CLOB/VARCHAR ● UUIDtype for java.util.UUID ● INTERVAL_SECONDtype for java.time.Duration ● INETtype for java.net.InetAddress Replace @TypeDefwith type safe variants i.e. @JavaTypeRegistration Replace @Typewith type safe variants i.e. @JavaType Mapping improvements
  • 22. Mapping improvements CompositeUserTypebridges gap between custom types and embeddables Embeddable mapper class for defining mapping structure Full control on construction and deconstruction of custom type ● Support for library types i.e. MonetaryAmount ● Repurpose existing types i.e. OffsetDateTime Out of the box support for Java records in discussion
  • 24. Other changes Switch to Jakarta Persistence Remove deprecated stuff i.e. legacy Criteria API Add type variables to APIs/SPIs where possible Dialectwas majorly updated Renaming of JavaTypeDescriptorand SqlTypeDescriptor See https://github.com/hibernate/hibernate-orm/blob/main/migration-guide.adoc
  • 25. What’s next? Subqueries in the from clause Common table expressions Lateral joins Insert-or-Update a.k.a. Upsert Table functions SQL structs SQL arrays
  • 26. Q & A