SlideShare a Scribd company logo
1 of 30
Download to read offline
What’s new in Hibernate 6.1?
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
Previously on “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
Previously on “What’s next?”...
Subqueries in the from clause (6.1)
Common table expressions
Lateral joins (6.1)
Insert-or-Update a.k.a. Upsert
Table functions
SQL structs
SQL arrays (6.1)
Previously on “What’s next?”...
Subqueries in the from clause (6.1)
Common table expressions (planned for 6.2)
Lateral joins (6.1)
Insert-or-Update a.k.a. Upsert (planned for 6.2)
Table functions
SQL structs
SQL arrays (6.1)
Demo time
https://github.com/beikov/presentation-hibernate-6
What’s next?
Common table expressions (planned for 6.2)
Insert-or-Update a.k.a. Upsert (planned for 6.2)
Table functions
SQL structs
SQL enums
JSON, XML and array functions
Joins in DML (update, delete)
Q & A
Extra slides
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
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/6.0/migration-guide.adoc

More Related Content

What's hot

Time Series Analytics with Spark: Spark Summit East talk by Simon Ouellette
Time Series Analytics with Spark: Spark Summit East talk by Simon OuelletteTime Series Analytics with Spark: Spark Summit East talk by Simon Ouellette
Time Series Analytics with Spark: Spark Summit East talk by Simon OuelletteSpark Summit
 
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
 
Troubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contentionTroubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contentionTanel Poder
 
The Magic of Window Functions in Postgres
The Magic of Window Functions in PostgresThe Magic of Window Functions in Postgres
The Magic of Window Functions in PostgresEDB
 
Building a Real-Time Analytics Application with Apache Pulsar and Apache Pinot
Building a Real-Time Analytics Application with  Apache Pulsar and Apache PinotBuilding a Real-Time Analytics Application with  Apache Pulsar and Apache Pinot
Building a Real-Time Analytics Application with Apache Pulsar and Apache PinotAltinity Ltd
 
Haskell vs. F# vs. Scala
Haskell vs. F# vs. ScalaHaskell vs. F# vs. Scala
Haskell vs. F# vs. Scalapt114
 
Tuning Apache Kafka Connectors for Flink.pptx
Tuning Apache Kafka Connectors for Flink.pptxTuning Apache Kafka Connectors for Flink.pptx
Tuning Apache Kafka Connectors for Flink.pptxFlink Forward
 
Arbitrary Stateful Aggregations using Structured Streaming in Apache Spark
Arbitrary Stateful Aggregations using Structured Streaming in Apache SparkArbitrary Stateful Aggregations using Structured Streaming in Apache Spark
Arbitrary Stateful Aggregations using Structured Streaming in Apache SparkDatabricks
 
Building a fully managed stream processing platform on Flink at scale for Lin...
Building a fully managed stream processing platform on Flink at scale for Lin...Building a fully managed stream processing platform on Flink at scale for Lin...
Building a fully managed stream processing platform on Flink at scale for Lin...Flink Forward
 
Apache Calcite: One planner fits all
Apache Calcite: One planner fits allApache Calcite: One planner fits all
Apache Calcite: One planner fits allJulian Hyde
 
Deep Dive: Memory Management in Apache Spark
Deep Dive: Memory Management in Apache SparkDeep Dive: Memory Management in Apache Spark
Deep Dive: Memory Management in Apache SparkDatabricks
 
How a Developer can Troubleshoot a SQL performing poorly on a Production DB
How a Developer can Troubleshoot a SQL performing poorly on a Production DBHow a Developer can Troubleshoot a SQL performing poorly on a Production DB
How a Developer can Troubleshoot a SQL performing poorly on a Production DBCarlos Sierra
 
SQL for NoSQL and how Apache Calcite can help
SQL for NoSQL and how  Apache Calcite can helpSQL for NoSQL and how  Apache Calcite can help
SQL for NoSQL and how Apache Calcite can helpChristian Tzolov
 
Tricks every ClickHouse designer should know, by Robert Hodges, Altinity CEO
Tricks every ClickHouse designer should know, by Robert Hodges, Altinity CEOTricks every ClickHouse designer should know, by Robert Hodges, Altinity CEO
Tricks every ClickHouse designer should know, by Robert Hodges, Altinity CEOAltinity Ltd
 
Oracle database performance tuning
Oracle database performance tuningOracle database performance tuning
Oracle database performance tuningAbishek V S
 
Improving SparkSQL Performance by 30%: How We Optimize Parquet Pushdown and P...
Improving SparkSQL Performance by 30%: How We Optimize Parquet Pushdown and P...Improving SparkSQL Performance by 30%: How We Optimize Parquet Pushdown and P...
Improving SparkSQL Performance by 30%: How We Optimize Parquet Pushdown and P...Databricks
 
Building an Activity Feed with Cassandra
Building an Activity Feed with CassandraBuilding an Activity Feed with Cassandra
Building an Activity Feed with CassandraMark Dunphy
 
KSQL Deep Dive - The Open Source Streaming Engine for Apache Kafka
KSQL Deep Dive - The Open Source Streaming Engine for Apache KafkaKSQL Deep Dive - The Open Source Streaming Engine for Apache Kafka
KSQL Deep Dive - The Open Source Streaming Engine for Apache KafkaKai Wähner
 

What's hot (20)

Flink Streaming
Flink StreamingFlink Streaming
Flink Streaming
 
Time Series Analytics with Spark: Spark Summit East talk by Simon Ouellette
Time Series Analytics with Spark: Spark Summit East talk by Simon OuelletteTime Series Analytics with Spark: Spark Summit East talk by Simon Ouellette
Time Series Analytics with Spark: Spark Summit East talk by Simon Ouellette
 
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...
 
Troubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contentionTroubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contention
 
The Magic of Window Functions in Postgres
The Magic of Window Functions in PostgresThe Magic of Window Functions in Postgres
The Magic of Window Functions in Postgres
 
Building a Real-Time Analytics Application with Apache Pulsar and Apache Pinot
Building a Real-Time Analytics Application with  Apache Pulsar and Apache PinotBuilding a Real-Time Analytics Application with  Apache Pulsar and Apache Pinot
Building a Real-Time Analytics Application with Apache Pulsar and Apache Pinot
 
Haskell vs. F# vs. Scala
Haskell vs. F# vs. ScalaHaskell vs. F# vs. Scala
Haskell vs. F# vs. Scala
 
Scala and spark
Scala and sparkScala and spark
Scala and spark
 
Tuning Apache Kafka Connectors for Flink.pptx
Tuning Apache Kafka Connectors for Flink.pptxTuning Apache Kafka Connectors for Flink.pptx
Tuning Apache Kafka Connectors for Flink.pptx
 
Arbitrary Stateful Aggregations using Structured Streaming in Apache Spark
Arbitrary Stateful Aggregations using Structured Streaming in Apache SparkArbitrary Stateful Aggregations using Structured Streaming in Apache Spark
Arbitrary Stateful Aggregations using Structured Streaming in Apache Spark
 
Building a fully managed stream processing platform on Flink at scale for Lin...
Building a fully managed stream processing platform on Flink at scale for Lin...Building a fully managed stream processing platform on Flink at scale for Lin...
Building a fully managed stream processing platform on Flink at scale for Lin...
 
Apache Calcite: One planner fits all
Apache Calcite: One planner fits allApache Calcite: One planner fits all
Apache Calcite: One planner fits all
 
Deep Dive: Memory Management in Apache Spark
Deep Dive: Memory Management in Apache SparkDeep Dive: Memory Management in Apache Spark
Deep Dive: Memory Management in Apache Spark
 
How a Developer can Troubleshoot a SQL performing poorly on a Production DB
How a Developer can Troubleshoot a SQL performing poorly on a Production DBHow a Developer can Troubleshoot a SQL performing poorly on a Production DB
How a Developer can Troubleshoot a SQL performing poorly on a Production DB
 
SQL for NoSQL and how Apache Calcite can help
SQL for NoSQL and how  Apache Calcite can helpSQL for NoSQL and how  Apache Calcite can help
SQL for NoSQL and how Apache Calcite can help
 
Tricks every ClickHouse designer should know, by Robert Hodges, Altinity CEO
Tricks every ClickHouse designer should know, by Robert Hodges, Altinity CEOTricks every ClickHouse designer should know, by Robert Hodges, Altinity CEO
Tricks every ClickHouse designer should know, by Robert Hodges, Altinity CEO
 
Oracle database performance tuning
Oracle database performance tuningOracle database performance tuning
Oracle database performance tuning
 
Improving SparkSQL Performance by 30%: How We Optimize Parquet Pushdown and P...
Improving SparkSQL Performance by 30%: How We Optimize Parquet Pushdown and P...Improving SparkSQL Performance by 30%: How We Optimize Parquet Pushdown and P...
Improving SparkSQL Performance by 30%: How We Optimize Parquet Pushdown and P...
 
Building an Activity Feed with Cassandra
Building an Activity Feed with CassandraBuilding an Activity Feed with Cassandra
Building an Activity Feed with Cassandra
 
KSQL Deep Dive - The Open Source Streaming Engine for Apache Kafka
KSQL Deep Dive - The Open Source Streaming Engine for Apache KafkaKSQL Deep Dive - The Open Source Streaming Engine for Apache Kafka
KSQL Deep Dive - The Open Source Streaming Engine for Apache Kafka
 

Similar to Hibernate 6.1 - What's new.pdf

MySQL 5.7 - What's new and How to upgrade
MySQL 5.7 - What's new and How to upgradeMySQL 5.7 - What's new and How to upgrade
MySQL 5.7 - What's new and How to upgradeAbel Flórez
 
MySQL 5.7 - What's new, How to upgrade and Document Store
MySQL 5.7 - What's new, How to upgrade and Document StoreMySQL 5.7 - What's new, How to upgrade and Document Store
MySQL 5.7 - What's new, How to upgrade and Document StoreAbel Flórez
 
MySQL Tech Tour 2015 - 5.7 Whats new
MySQL Tech Tour 2015 - 5.7 Whats newMySQL Tech Tour 2015 - 5.7 Whats new
MySQL Tech Tour 2015 - 5.7 Whats newMark Swarbrick
 
Upgrade to MySQL 5.7 and latest news planned for MySQL 8
Upgrade to MySQL 5.7 and latest news planned for MySQL 8Upgrade to MySQL 5.7 and latest news planned for MySQL 8
Upgrade to MySQL 5.7 and latest news planned for MySQL 8Ted Wennmark
 
Deep dive into Hibernate ORM 6.4 features
Deep dive into Hibernate ORM 6.4 featuresDeep dive into Hibernate ORM 6.4 features
Deep dive into Hibernate ORM 6.4 featuresChristian Beikov
 
The Java EE 6 platform
The Java EE 6 platformThe Java EE 6 platform
The Java EE 6 platformLorraine JUG
 
qb for the rest of us - sam knowlton
qb for the rest of us - sam knowltonqb for the rest of us - sam knowlton
qb for the rest of us - sam knowltonOrtus Solutions, Corp
 
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
 
Hypertable
HypertableHypertable
Hypertablebetaisao
 
Meetup cassandra sfo_jdbc
Meetup cassandra sfo_jdbcMeetup cassandra sfo_jdbc
Meetup cassandra sfo_jdbczznate
 
SQL Server 2008 Integration Services
SQL Server 2008 Integration ServicesSQL Server 2008 Integration Services
SQL Server 2008 Integration ServicesEduardo Castro
 
What's New In PostgreSQL 9.4
What's New In PostgreSQL 9.4What's New In PostgreSQL 9.4
What's New In PostgreSQL 9.4Pavan Deolasee
 
Fast federated SQL with Apache Calcite
Fast federated SQL with Apache CalciteFast federated SQL with Apache Calcite
Fast federated SQL with Apache CalciteChris Baynes
 
Ms sql server architecture
Ms sql server architectureMs sql server architecture
Ms sql server architectureAjeet Singh
 
State of entity framework
State of entity frameworkState of entity framework
State of entity frameworkDavid Paquette
 
The latest with MySql on OpenStack Trove
The latest with MySql on OpenStack TroveThe latest with MySql on OpenStack Trove
The latest with MySql on OpenStack TroveTesora
 
DjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling DisqusDjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling Disquszeeg
 
Apache Kylin: OLAP Engine on Hadoop - Tech Deep Dive
Apache Kylin: OLAP Engine on Hadoop - Tech Deep DiveApache Kylin: OLAP Engine on Hadoop - Tech Deep Dive
Apache Kylin: OLAP Engine on Hadoop - Tech Deep DiveXu Jiang
 

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

MySQL 5.7 - What's new and How to upgrade
MySQL 5.7 - What's new and How to upgradeMySQL 5.7 - What's new and How to upgrade
MySQL 5.7 - What's new and How to upgrade
 
MySQL 5.7 - What's new, How to upgrade and Document Store
MySQL 5.7 - What's new, How to upgrade and Document StoreMySQL 5.7 - What's new, How to upgrade and Document Store
MySQL 5.7 - What's new, How to upgrade and Document Store
 
MySQL Tech Tour 2015 - 5.7 Whats new
MySQL Tech Tour 2015 - 5.7 Whats newMySQL Tech Tour 2015 - 5.7 Whats new
MySQL Tech Tour 2015 - 5.7 Whats new
 
Upgrade to MySQL 5.7 and latest news planned for MySQL 8
Upgrade to MySQL 5.7 and latest news planned for MySQL 8Upgrade to MySQL 5.7 and latest news planned for MySQL 8
Upgrade to MySQL 5.7 and latest news planned for MySQL 8
 
Deep dive into Hibernate ORM 6.4 features
Deep dive into Hibernate ORM 6.4 featuresDeep dive into Hibernate ORM 6.4 features
Deep dive into Hibernate ORM 6.4 features
 
The Java EE 6 platform
The Java EE 6 platformThe Java EE 6 platform
The Java EE 6 platform
 
qb for the rest of us - sam knowlton
qb for the rest of us - sam knowltonqb for the rest of us - sam knowlton
qb for the rest of us - sam knowlton
 
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
 
Hypertable Nosql
Hypertable NosqlHypertable Nosql
Hypertable Nosql
 
Hypertable
HypertableHypertable
Hypertable
 
Sqlapi0.1
Sqlapi0.1Sqlapi0.1
Sqlapi0.1
 
Meetup cassandra sfo_jdbc
Meetup cassandra sfo_jdbcMeetup cassandra sfo_jdbc
Meetup cassandra sfo_jdbc
 
SQL Server 2008 Integration Services
SQL Server 2008 Integration ServicesSQL Server 2008 Integration Services
SQL Server 2008 Integration Services
 
What's New In PostgreSQL 9.4
What's New In PostgreSQL 9.4What's New In PostgreSQL 9.4
What's New In PostgreSQL 9.4
 
Fast federated SQL with Apache Calcite
Fast federated SQL with Apache CalciteFast federated SQL with Apache Calcite
Fast federated SQL with Apache Calcite
 
Ms sql server architecture
Ms sql server architectureMs sql server architecture
Ms sql server architecture
 
State of entity framework
State of entity frameworkState of entity framework
State of entity framework
 
The latest with MySql on OpenStack Trove
The latest with MySql on OpenStack TroveThe latest with MySql on OpenStack Trove
The latest with MySql on OpenStack Trove
 
DjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling DisqusDjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling Disqus
 
Apache Kylin: OLAP Engine on Hadoop - Tech Deep Dive
Apache Kylin: OLAP Engine on Hadoop - Tech Deep DiveApache Kylin: OLAP Engine on Hadoop - Tech Deep Dive
Apache Kylin: OLAP Engine on Hadoop - Tech Deep Dive
 

Recently uploaded

Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 

Recently uploaded (20)

Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 

Hibernate 6.1 - What's new.pdf

  • 1. What’s new in Hibernate 6.1? 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. Previously on “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
  • 4. Previously on “What’s next?”... Subqueries in the from clause (6.1) Common table expressions Lateral joins (6.1) Insert-or-Update a.k.a. Upsert Table functions SQL structs SQL arrays (6.1)
  • 5. Previously on “What’s next?”... Subqueries in the from clause (6.1) Common table expressions (planned for 6.2) Lateral joins (6.1) Insert-or-Update a.k.a. Upsert (planned for 6.2) Table functions SQL structs SQL arrays (6.1)
  • 7. What’s next? Common table expressions (planned for 6.2) Insert-or-Update a.k.a. Upsert (planned for 6.2) Table functions SQL structs SQL enums JSON, XML and array functions Joins in DML (update, delete)
  • 10. 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
  • 11. 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
  • 12. 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=?
  • 13. 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
  • 14. 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
  • 15. 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
  • 16. 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 ) );
  • 17. 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
  • 18. 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 );
  • 19. 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
  • 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 .. ..
  • 21. 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
  • 22. 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
  • 23. Query improvements ILIKEpredicate support select e from Entity e where e.name ilike ‘%tony%’ Fallback to lower(e.name) like lower(‘%tony’)
  • 24. 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.
  • 25. Query improvements Session#createSelectionQueryfor select only queries ● No executeUpdatemethod Session#createMutationQueryfor mutation only queries ● No getResultList/getSingleResultetc. methods Early validations and communication of intent
  • 26. 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, …)
  • 27. 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
  • 28. 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
  • 29. 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
  • 30. 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/6.0/migration-guide.adoc