the hibernate project: moving forward to newsql and beyond

49
The Hibernate project: moving forward to NewSQL and beyond Sanne Grinovero Hibernate team Sr Principal Software Engineer Red Hat

Upload: sanne-grinovero

Post on 28-Jan-2018

35 views

Category:

Data & Analytics


0 download

TRANSCRIPT

Page 1: The Hibernate Project: Moving Forward to NewSQL and Beyond

The Hibernate project: movingforward to NewSQL and

beyondSanne Grinovero Hibernate team

Sr Principal Software Engineer Red Hat

Page 2: The Hibernate Project: Moving Forward to NewSQL and Beyond

Take awayRefresh of Hibernate

Overview of Hibernate projects

What’s new?

What’s next?

Page 3: The Hibernate Project: Moving Forward to NewSQL and Beyond

Sanne Grinovero10+ years working with & on Hibernate

Team blog: Twitter:

in.relation.to@SanneGrinovero

Contributing to many more OSS projects in the data space

Apache Lucene, Elasticsearch

WildFly, JBoss Enterprise Application Server

In�nispan, JBoss Data Grid

Red Hat, 7+ years

Page 4: The Hibernate Project: Moving Forward to NewSQL and Beyond
Page 5: The Hibernate Project: Moving Forward to NewSQL and Beyond

How is it doing?

Page 6: The Hibernate Project: Moving Forward to NewSQL and Beyond

Let’s take some Maven stats

A,B,C,D are well known, economically viable projects, anonymisedfor their protection

Page 7: The Hibernate Project: Moving Forward to NewSQL and Beyond

… then include Hibernate stats

The scale had to change. {A..D} hare not missing.

Page 8: The Hibernate Project: Moving Forward to NewSQL and Beyond

Need to use a Logarithmicscale ?!

Page 9: The Hibernate Project: Moving Forward to NewSQL and Beyond

Looking at geographicalusage

Bangalore, India has most daily downloads

Guess China ?

Page 10: The Hibernate Project: Moving Forward to NewSQL and Beyond

Java Persistence APIJPA

Hibernate implements the standard interface

The Hibernate community in�uences next gen spec

Recruiters get very confused

Page 11: The Hibernate Project: Moving Forward to NewSQL and Beyond

Hibernate Portfolio

Page 12: The Hibernate Project: Moving Forward to NewSQL and Beyond

EcosystemJava EE (JPA implementation, JBoss EAP, WildFly)

Spring, Spring Boot

Groovy / Grails

Many many more!

loads of tooling

Page 13: The Hibernate Project: Moving Forward to NewSQL and Beyond

Hibernate ORM 5

Page 14: The Hibernate Project: Moving Forward to NewSQL and Beyond

CleanupBootstrap via well de�ned phases

Modularity

WildFly, OSGi, Java 9

extensions, integration points with ORM

Performance

Page 15: The Hibernate Project: Moving Forward to NewSQL and Beyond

Java8: Date and TimeDATE: java.time.LocalDate

TIME: java.time.LocalTime, java.time.OffsetTime

TIMESTAMP: java.time.Instant, java.time.LocalDateTime,java.time.OffsetDateTime and java.time.ZonedDateTime

Page 16: The Hibernate Project: Moving Forward to NewSQL and Beyond

AutoClosable, Genericstry ( Session session = sessionFactory.openSession() ) { Address address = session.get(Address.class, id); return address.getCity(); }

AutoClosable resources:

Session / StatelessSession

SessionFactory

ScrollableResults

Page 17: The Hibernate Project: Moving Forward to NewSQL and Beyond

Bytecode instrumentationSmarter change detection

Better Maven and Gradle support

Lazy loading of properties

sub-groups

Automatic bi-directional management

Page 18: The Hibernate Project: Moving Forward to NewSQL and Beyond

Association management -before

//Create relation Order order = new Order(); LineItem lineItem = new LineItem(); order.getLineItems().add( lineItem ); lineItem.setOrder( order );

//Relation established: lineItem.getOrder().getName();

Page 19: The Hibernate Project: Moving Forward to NewSQL and Beyond

Association management -after

//Create relation Order order = new Order(); LineItem lineItem = new LineItem(); order.getLineItems().add( lineItem ); //lineItem.setOrder( order ); Not required!

//Relation established: lineItem.getOrder().getName(); // NPE automatically prevented!

Page 20: The Hibernate Project: Moving Forward to NewSQL and Beyond

ByteBuddyNew ByteButty based enhancer, thanks to Rafael Winterhalter

To replace Javassist?

No runtime dependency

Based on ASM

Page 21: The Hibernate Project: Moving Forward to NewSQL and Beyond

SAP HANAA new exotic database…

Support for the powerful SAP HANA "in memory data platform"

Thanks to the SAP engineers!

Not just a new Dialect

What’s next?

Page 22: The Hibernate Project: Moving Forward to NewSQL and Beyond

Second level cacheOptimisations on the key types

Cache by reference (immutable entities)

JCache integration point

Page 23: The Hibernate Project: Moving Forward to NewSQL and Beyond

Second level cache, byreference

<property name="hibernate.cache.use_reference_entries" values=“true"/>

@Entity @Immutable @Cacheable @Cache( usage = CacheConcurrencyStrategy.READ_ONLY ) public class MyReferenceData { @Id private Integer id; private String name; private String theValue; .... }

Page 24: The Hibernate Project: Moving Forward to NewSQL and Beyond

Hibernate Search

Page 25: The Hibernate Project: Moving Forward to NewSQL and Beyond

Full-text searchInverted index

Object level

Clustered

Elasticsearch

Page 26: The Hibernate Project: Moving Forward to NewSQL and Beyond

What is new in 5+?Upgrade Lucene without breaking APIs

Signi�cant perf improvements

since 5.6: Elasticsearch !

WildFly Swarm and Spring Boot

Page 27: The Hibernate Project: Moving Forward to NewSQL and Beyond

An @Indexed @Entity@Indexed @Entity public class Address { @Id Integer id;

@Field String street1;

@Field(analyze=NO) @SortableField @Facet String city;

@IndexedEmbedded Country country;

... }

Page 28: The Hibernate Project: Moving Forward to NewSQL and Beyond

What’s coming in HibernateSearch 6?

Full abstraction from Lucene API

easier to plug additional full-text engines

HANA?

Page 29: The Hibernate Project: Moving Forward to NewSQL and Beyond

Hibernate OGMAn ORM for NOSQL ? OMG!!

Page 30: The Hibernate Project: Moving Forward to NewSQL and Beyond

JPA for NoSQLMongoDB

In�nispan

Neo4J

Redis

EhCache

Cassandra

CouchDB

Page 31: The Hibernate Project: Moving Forward to NewSQL and Beyond

First steps to get started<dependencies> <dependency> <groupId>org.hibernate.ogm</groupId> <artifactId>hibernate-ogm-neo4j</artifactId> </dependency> </dependencies>

<persistence> <persistence-unit name="ogm-neo4j" transaction-type="JTA"> <!-- Use Hibernate OGM provider: configuration will be transparent --> <provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider> <properties> <property name="hibernate.ogm.datastore.provider" value="neo4j"/> </properties> </persistence-unit> </persistence>

Page 32: The Hibernate Project: Moving Forward to NewSQL and Beyond

How to use OGMIt’s just JPA!

Java Persistence API

Page 33: The Hibernate Project: Moving Forward to NewSQL and Beyond

How to integrate with OGMIt’s just Hibernate!

Page 34: The Hibernate Project: Moving Forward to NewSQL and Beyond

Hibernate Validator

Page 35: The Hibernate Project: Moving Forward to NewSQL and Beyond

Bean Validation 2.0beanvalidation.org

Page 36: The Hibernate Project: Moving Forward to NewSQL and Beyond

class User { @Email String email; @Positive int age; @NotNull @Size(max=50) String firstName; }

@Stateless class UserService { public void createUser(@Valid @NotNull User user) { ... } }

Page 37: The Hibernate Project: Moving Forward to NewSQL and Beyond

Collections and othercontainers

public class User { @Size(max=10) public List<@NotNull @Email String> emails;

Optional<@Email String> defaultEmail; }

Page 38: The Hibernate Project: Moving Forward to NewSQL and Beyond

Validator 6: faster!http://in.relation.to/2017/10/31/bean-validation-benchmark-

revisited/

Page 39: The Hibernate Project: Moving Forward to NewSQL and Beyond

Hibernate Spatial

Page 40: The Hibernate Project: Moving Forward to NewSQL and Beyond

Hibernate Search Spatial vsHibernate Spatial

Hibernate Search uses Lucene indices outside of the database

can be combined with full-text, relevance "fuzzy logic"

Hibernate (ORM) Spatial uses RDBMS spatial functions

Oracle DB, Postgis (PostgreSQL), MySQL, GeoDB (H2),SQLServer, HANA

Page 41: The Hibernate Project: Moving Forward to NewSQL and Beyond

Code !org.hibernate:hibernate-spatial

hibernate.dialect=org.hibernate.spatial.dialect.postgis.Postgis

@Entity(name = "Event") public class Event {

@Id Long id;

@Type(type = "jts_geometry") Point location; }

Page 42: The Hibernate Project: Moving Forward to NewSQL and Beyond

QueryEvent event = entityManager.createQuery( "select e " + "from Event e " + "where within(e.location, :filter) = true", Event.class) .setParameter("filter", new WKTReader().read( "POLYGON((1 1,20 1,20 20,1 20,1 1))")) .getSingleResult();

Page 43: The Hibernate Project: Moving Forward to NewSQL and Beyond

Hibernate EnversIs getting more love

Page 44: The Hibernate Project: Moving Forward to NewSQL and Beyond

Hibernate 6 & beyond

Page 45: The Hibernate Project: Moving Forward to NewSQL and Beyond

Semantic Query ModelRefactoring Hibernate’s Type contract to unify Hibernate ORM, JPAand SQM type systems

Query and SQL execution performance

Migration to SQM for query interpretation/representationHQL/JPQL

(JPA) criteria queries

Page 46: The Hibernate Project: Moving Forward to NewSQL and Beyond

And much more… Jandex based annotation scanning

Always more performance

new Connection pool integrations

Using new tools extensively during design: JMH, java-object-layout

OSGi, Java 9: better modularity

Page 47: The Hibernate Project: Moving Forward to NewSQL and Beyond

Java 9Hibernate ORM → just works

Hibernate Validator → just works

Hibernate Search → just works

Hibernate OGM → WIP, depends on the NoSQL database

Not as modules yet!

Page 48: The Hibernate Project: Moving Forward to NewSQL and Beyond

ConclusionsReliable yet innovating

Comprehensive data platform

way beyond the 10y old relational-only ORM !

A friendly, open, deeply technical community

Page 49: The Hibernate Project: Moving Forward to NewSQL and Beyond

Q&ATry Hibernate *, you’ll love them

Contribute: feedback, battle stories, advice, code, (failing) tests..

http://hibernate.org/