The document outlines Oracle's general product direction but does not constitute a commitment and features are at Oracle's sole discretion. It provides an overview of Java Persistence API 2.0 which offers expanded modeling capabilities, additional mapping options, improvements to the query language, and support for validation and locking compared to JPA 1.0. Key features include collections of basic types and embeddables, a Criteria API, and support in Java EE 6 via GlassFish.
Your code sucks, let's fix it - DPC UnConRafael Dohms
How do you measure the quality of your code? Performance and testing are just one aspect of code, in order to meet deadlines and make maintenance quicker you also need your code to be readable, decoupled and generally easier to comprehend and work with. This talk will go over tips and exercises to help you identify trouble areas, refactor them and train you to write better code in future projects. Come make your code look and function better.
Con la versione 7 di Drupal è stato introdotto il concetto di Entity, poi evoluto con la versione 8, utilizzato come base di buona parte degli elementi core (nodi, tassonomie, utenti, ...), ma - soprattutto - è stata data la possibilità di costruire entity custom. L'utilizzo di queste apre le possibilità di personalizzazione dello strumento ad un livello superiore velocizzando notevolmente lo sviluppo.
Verranno mostrate le potenzialità nell'uso delle Entity custom e le integrazioni possibili.
Cloudera Sessions - Clinic 3 - Advanced Steps - Fast-track Development for ET...Cloudera, Inc.
Working with Hadoop does not always mean starting from scratch. In this session, you’ll learn how to leverage your existing investments in tools and skills to accelerate your Hadoop development. Learn from experts as they walk you step-by-step through the conversion of an existing ETL process to use Big Data.
Top Ten Reasons to Use EntityFieldQuery in DrupalFredric Mitchell
Drupal 7 introduced a great class, EntityFieldQuery (EFQ), to easily grab information from entities that was not available in Drupal 6.
This session will explore why you should be already using EFQ in your development practices. We'll also review how to use it and explore it's relationship with Drupal view modes and block entities (Beans).
This session will also explore comparisons with Views, and how EFQ should replace some of the common development practices using Views as a query tool.
EFQ Top Ten
Core
Well Documented
Simple
Consumable
Object-Oriented
Extensible
Alterable
Exception Handling
View Modes
Beans
Drupal Entities - Emerging Patterns of UsageRonald Ashri
Entities are a powerful architectural approach and tool introduced in Drupal 7 - in this presentation I explain what they are and how they can be used with references to examples of how entities are used already.
Its conciseness, versatility and DSL capabilities makes Scala desirable for scripting. In this report we show how we implemented a JSR223 compliant script engine for Scala which runs inside OSGi environments.
While the Scala compiler needs a class path to load class files, OSGi only provides class loaders. To overcome this we implemented a file system abstraction on top of OSGi bundles effectively providing a class path. Furthermore, JSR223's dynamic approach for passing arguments does not play well with Scala's static types. We need to make all types of arguments visible to scripts. Our implementation generates a preamble of adequate implicit conversions which allows scripts to use statically typed variables in a manner resembling dynamic types. Finally performance constraints require caching of pre-compiled scripts.
Apache Sling, an OSGi based web application framework with a scriptable application layer, uses our implementation for type safe templating via Scala's XML support.
It's back...
AND it's better than ever, DBTNG (Database: The Next Generation) is nothing to be scared of and we'll show how easy it is to create both static and dynamic query statements for use in your custom modules and Drupal 6 to Drupal 7 module migration work. In this session we'll take a look at the Drupal 7 database abstraction layer and the database API and cover:
To db_query or not to db_query?
Dynamic query syntax and fluid interfaces
Working with result sets
Joins, conditional statements, subselects and sorting with db_select
Tagging your db_select queries for hook awareness
Decorator patterns for db_select -
db_update, db_insert, db_delete and our new friend, db_merge
Explore alternatives to views and how and when to make that call.
After this session attendees will be ready for Drupal III: Drupalicon Takes Manhattan
Presentation I gave at the Berkeley Drupal Users Group on February 27, 2012 covering entities in Drupal 7 including entity types, bundles, fields, nodes, the Entity API and the Schema API. I use TextbookMadness.com as an example of how to leverage entities.
Click on my name to find a newer (better!) version of these slides.
Your code sucks, let's fix it - DPC UnConRafael Dohms
How do you measure the quality of your code? Performance and testing are just one aspect of code, in order to meet deadlines and make maintenance quicker you also need your code to be readable, decoupled and generally easier to comprehend and work with. This talk will go over tips and exercises to help you identify trouble areas, refactor them and train you to write better code in future projects. Come make your code look and function better.
Con la versione 7 di Drupal è stato introdotto il concetto di Entity, poi evoluto con la versione 8, utilizzato come base di buona parte degli elementi core (nodi, tassonomie, utenti, ...), ma - soprattutto - è stata data la possibilità di costruire entity custom. L'utilizzo di queste apre le possibilità di personalizzazione dello strumento ad un livello superiore velocizzando notevolmente lo sviluppo.
Verranno mostrate le potenzialità nell'uso delle Entity custom e le integrazioni possibili.
Cloudera Sessions - Clinic 3 - Advanced Steps - Fast-track Development for ET...Cloudera, Inc.
Working with Hadoop does not always mean starting from scratch. In this session, you’ll learn how to leverage your existing investments in tools and skills to accelerate your Hadoop development. Learn from experts as they walk you step-by-step through the conversion of an existing ETL process to use Big Data.
Top Ten Reasons to Use EntityFieldQuery in DrupalFredric Mitchell
Drupal 7 introduced a great class, EntityFieldQuery (EFQ), to easily grab information from entities that was not available in Drupal 6.
This session will explore why you should be already using EFQ in your development practices. We'll also review how to use it and explore it's relationship with Drupal view modes and block entities (Beans).
This session will also explore comparisons with Views, and how EFQ should replace some of the common development practices using Views as a query tool.
EFQ Top Ten
Core
Well Documented
Simple
Consumable
Object-Oriented
Extensible
Alterable
Exception Handling
View Modes
Beans
Drupal Entities - Emerging Patterns of UsageRonald Ashri
Entities are a powerful architectural approach and tool introduced in Drupal 7 - in this presentation I explain what they are and how they can be used with references to examples of how entities are used already.
Its conciseness, versatility and DSL capabilities makes Scala desirable for scripting. In this report we show how we implemented a JSR223 compliant script engine for Scala which runs inside OSGi environments.
While the Scala compiler needs a class path to load class files, OSGi only provides class loaders. To overcome this we implemented a file system abstraction on top of OSGi bundles effectively providing a class path. Furthermore, JSR223's dynamic approach for passing arguments does not play well with Scala's static types. We need to make all types of arguments visible to scripts. Our implementation generates a preamble of adequate implicit conversions which allows scripts to use statically typed variables in a manner resembling dynamic types. Finally performance constraints require caching of pre-compiled scripts.
Apache Sling, an OSGi based web application framework with a scriptable application layer, uses our implementation for type safe templating via Scala's XML support.
It's back...
AND it's better than ever, DBTNG (Database: The Next Generation) is nothing to be scared of and we'll show how easy it is to create both static and dynamic query statements for use in your custom modules and Drupal 6 to Drupal 7 module migration work. In this session we'll take a look at the Drupal 7 database abstraction layer and the database API and cover:
To db_query or not to db_query?
Dynamic query syntax and fluid interfaces
Working with result sets
Joins, conditional statements, subselects and sorting with db_select
Tagging your db_select queries for hook awareness
Decorator patterns for db_select -
db_update, db_insert, db_delete and our new friend, db_merge
Explore alternatives to views and how and when to make that call.
After this session attendees will be ready for Drupal III: Drupalicon Takes Manhattan
Presentation I gave at the Berkeley Drupal Users Group on February 27, 2012 covering entities in Drupal 7 including entity types, bundles, fields, nodes, the Entity API and the Schema API. I use TextbookMadness.com as an example of how to leverage entities.
Click on my name to find a newer (better!) version of these slides.
Presentation made at JavaONE, Hyderabad, on 10th May 2011. Slides are a slightly modified version of what's presented by Linda D. at JavaONE, SF, in 2010.
Spring Data is a high level SpringSource project whose purpose is to unify and ease the access to different kinds of persistence stores, both relational database systems and NoSQL data stores.
Spring Day | Spring and Scala | Eberhard WolffJAX London
2011-10-31 | 09:45 AM - 10:30 AM
Spring is widely used in the Java world - but does it make any sense to combine it with Scala? This talk gives an answer and shows how and why Spring is useful in the Scala world. All areas of Spring such as Dependency Injection, Aspect-Oriented Programming and the Portable Service Abstraction as well as Spring MVC are covered.
Spring Data Requery is alternatives of Spring Data JPA
Requery is lightweight ORM for DBMS (MySQL, PostgreSQL, H2, SQLite, Oracle, SQL Server)
Spring Data Requery provide Query By Native Query, Query By Example and Query By Property like Spring Data JPA
Spring Data Requery is better performance than JPA
Swift offers a compelling opportunity to build reliable, scalable and lightweight micro-services. This talk will discuss how I am investigating the use of Swift micro-services - running in ECS and potentially Lambda, fronted by API gateway - with AWS technologies such as managing data models with DynamoDb.
Using the Tooling API to Generate Apex SOAP Web Service ClientsDaniel Ballinger
Presentation from Dreamforce 2014 on using the Tooling API to create increased support for calling SOAP based web services using WSDLs to generate Apex.
Alternatives of JPA
Requery provide simple Object Mapping & Generate SQL to execute without reflection and session, so fast than JPA, simple and easy to learn.
1. The following is intended to outline our general
product direction. It is intended for information
purposes only, and may not be incorporated into
any contract. It is not a commitment to deliver
any material, code, or functionality, and should
not be relied upon in making purchasing
decisions.
The development, release, and timing of any
features or functionality described for Oracle’s
products remains at the sole discretion of
Oracle.
1
2. <Insert Picture Here>
JavaTM Persistence API 2.0: An Overview
Ludovic Champenois
Architect – GlassFish, NetBeans, Eclipse
3. JavaTM Persistence API: Brief History
• Java Persistence 1.0
– Standardized object/relational mapping for Java applications
– Available as part Java EE 5 Platform or standalone
– Covered most of the essential features
• Java Persistence 2.0
– More and better increased application portability
– Released in December 2009
– Available as part of Java EE 6 Platform or standalone
– Reference Implementation is EclipseLink
– Available as part of GlassFish v3
3
4. JavaTM Persistence 2.0: New Features
• Expanded modeling capabilities
• Additional O/R mapping options
• Additions to Java Persistence query language
• Criteria API
• Metamodel API
• Pessimistic locking
• Support for Bean Validation
4
5. JavaTM Persistence 2.0:
Expanded modeling and mapping
• Collections of basic types
• Collections of embeddables
• Richer support for embeddable classes
– Multiple levels of embedding
– Embeddable classes with relationships
• Persistently ordered lists
• Improved map support
– Joins with additional columns
– Ternary relationships
• Orphan deletion
5
6. Collections of Basic Types and Embeddables
• Collections of strings, integers, etc.
• Collections of embeddables (e.g., Address, Detail)
• Specified by @ElementCollection
• Stored in “collection table”
• Customize mappings with:
– @CollectionTable
– @Column (for basic types)
– @AttributeOverride, @AssociationOverride (for embeddables)
6
7. Collections of Basic Types
@Entity
public class Person {
@Id protected String ssn;
protected String name;
protected Date birthDate;
...
@ElementCollection
protected Set<String> nickNames;
...
}
7
8. Collections of Basic Types
PERSON
SSN NAME BIRTHDATE
PERSON_NICKNAMES
PERSON_SSN NICKNAMES
8
9. Collections of Basic Types
@Entity
public class Person {
@Id protected String ssn;
protected String name;
protected Date birthDate;
...
@ElementCollection
@CollectionTable(name=“ALIASES”)
@Column(name=“ALIAS”)
protected Set<String> nickNames;
...
}
9
10. Collections of Basic Types
PERSON
SSN NAME BIRTHDATE
ALIASES
PERSON_SSN ALIAS
10
11. Collections of Embeddable Types
@Entity public class Landlord {
@Id String taxId;
String name;
@ElementCollection
@CollectionTable(name=“rentals”)
Set<Address> properties;
...
}
@Embeddable public class Address {
String street;
String city;
String state;
...
}
11
13. Persistently Ordered Lists
• Order is maintained in database by provider
– Uses additional (integral) ordering column
• Specified with @OrderColumn
• Provides alternative to @OrderBy
13
14. Persistently Ordered Lists
@Entity public class CreditCard {
@Id String cardNumber;
@ManyToOne Customer customer;
...
@OneToMany(mappedBy=“creditCard”)
@OrderColumn(name=“TXORDER”)
List<CardTransaction> transactionHistory;
...
}
@Entity public class CardTransaction {
@Id @GeneratedValue Long id;
@ManyToOne @JoinColumn(name=“CARDID”)
CreditCard creditCard;
@Temporal(DATE) Date txDate;
...
}
14
16. Automatic Orphan Deletion
• Deletion of related entities when removed from
relationship or when referencing entity is removed
– For entities logically “owned” by “parent”
– For one-to-one and one-to-many relationships
• Specified with orphanRemoval element
cascade=CascadeType.REMOVE is redundant
16
17. Orphan Deletion
@Entity
public class Order {
@Id int orderId;
...
@OneToMany(cascade=CascadeType.PERSIST,
orphanRemoval=true)
Set<Item> items;
}
17
18. Java Persistence Query Language:
New Functionality
• Support for all new modeling and mapping features
• Operators and functions in select list
• Case, coalesce, nullif expressions
• Restricted polymorphism
• Collection-valued input parameters
• Date / time / timestamp literals
18
19. New Operators
• INDEX
– For ordered lists
• KEY, VALUE, ENTRY
– For maps
• CASE, COALESCE, NULLIF
– For case expressions and the like
• TYPE
– For entity type expressions / restricted polymorphism
19
20. Ordered Lists, Date Literals
SELECT t
FROM CreditCard c JOIN c.transactionHistory t
WHERE c.customer.name = 'John Doe'
AND INDEX(t) < 100
AND t.txDate <= {d '2010-6-30'}
20
22. Criteria API
• Object-based API for building queries
• Designed to mirror JPQL semantics
• Strongly typed
– Heavy use of Java generics
– Based on type-safe metamodel of persistence unit
– Typing carries through to query execution as well
• Supports object-based or string-based navigation
22
23. Criteria API: Core Interfaces
• CriteriaQuery
– Represents a query definition object
– Used to add / replace / browse constituent query elements
– select, from, where, orderBy, groupBy, having,… methods
• CriteriaBuilder
– Factory for CriteriaQuery objects
– Obtained from EntityManager or EntityManagerFactory
– Used to create selections, expressions, restrictions, orderings…
• Root
– Query root
23
24. Criteria API: Core Interfaces
• Join, ListJoin, MapJoin,…
– Joins from a root or existing join
• Path
– Navigation from a root, join, path
• Subquery
• Parameter
• TypedQuery
– Executable query object
– Extends Query interface
• Tuple
– Multiple-valued result type
24
25. How to Build (and Execute) a Criteria Query
CriteriaBuilder cb = ...;
CriteriaQuery<ResultType> cq =
cb.createQuery(ResultType.class);
Root<SomeEntity> e = cq.from(SomeEntity.class);
Join<SomeEntity,RelatedEntity> j = e.join(...);
...
// the following in any order:
cq.select(…)
.where(…)
.orderBy(…)
.groupBy(…)
.having(…);
TypedQuery<ResultType> tq = em.createQuery(cq);
List<ResultType> results = tq.getResultList();
25
26. The World’s Simplest Query
SELECT c
FROM Customer c
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Customer> cq =
cb.createQuery(Customer.class);
Root<Customer> c = cq.from(Customer.class);
cq.select(c);
List<Customer> result =
em.createQuery(cq).getResultList();
26
27. Joins and Navigation
SELECT c
FROM Customer c join c.orders o
CriteriaBuilder cb = ...;
CriteriaQuery<Customer> cq =
cb.createQuery(Customer.class);
Root<Customer> c = cq.from(Customer.class);
Join<Customer, Order> o = customer.join(“orders”);
cq.select(c);
27
28. Joins and Navigation: What’s the Problem?
SELECT c
FROM Customer c join c.orders o
CriteriaBuilder cb = ...;
CriteriaQuery<Customer> cq =
cb.createQuery(Customer.class);
Root<Customer> c = cq.from(Customer.class);
Join<Customer, Order> o = customer.join(“wombats”);
cq.select(c);
28
29. Metamodel
• Abstract, “schema-level” view of managed classes of
persistence unit
– Entities, mapped superclasses, embeddables, and their
attributes and relationships
• Accessible at runtime
– EntityManagerFactory.getMetamodel()
– EntityManager.getMetamodel()
• Useful for frameworks
• Provides foundation for type-safe queries
• Can be materialized as static metamodel classes
– Use javac + annotation processor
29
30. Example: Entity Class
@Entity
public class Customer {
@Id int id;
String name;
Address address;
...
@OneToMany Set<Order> orders;
@ManyToOne SalesRep rep;
...
}
30
31. Example: Canonical Static Metamodel Class
import javax.persistence.metamodel.*
@Generated(“EclipseLink JPA 2.0 Canonical Model Generation”)
@StaticMetamodel(Customer.class)
public class Customer_ {
public static volatile SingularAttribute<Customer, Integer> id;
public static volatile SingularAttribute<Customer, String> name;
public static volatile SingularAttribute<Customer, Address>
address;
public static volatile SetAttribute<Customer, Order> orders;
public static volatile SingularAttribute<Customer, SalesRep> rep;
...
}
31
32. Type-safe Navigation
SELECT c
FROM Customer c join c.orders o
CriteriaBuilder cb = ...;
CriteriaQuery<Customer> cq = cb.createQuery(Customer.class);
Root<Customer> c = cq.from(Customer.class);
Join<Customer, Order> o = customer.join(Customer_.orders);
cq.select(c);
32
33. Locking
• JPA 1.0 only supported optimistic read or optimistic
write locking
– At commit time, JPA checked the version Attribute
– Assumed infrequent conflicts
• JPA 2.0 introduces Pessimistic locking
– A transaction that reads data locks it
– Another transaction cannot change it before the 1rst
transaction commits the read
– Assume frequent conflicts
• In total, now 5 lock modes
– Optimistic, Optimistic_force_increment, Pessimistic_read,
Pessimistic_write, Pessimistic_force_increment
33
37. Summary
• Expanded modeling capabilities
• Additional O/R mapping options
• Additions to Java Persistence query language
• Metamodel API
• Criteria API
• Pessimistic locking
• Support for validation
• Improved portability
37
38. Resources
• Java Persistence 2.0 Specification
http://jcp.org/en/jsr/detail?id=317
• Reference Implementation is EclipseLink
http://www.eclipse.org/eclipselink
• Available as part of Java EE 6 with GlassFish
http://glassfish.org
• Book: Pro JPA 2 (Keith & Schincariol)
38