Keep Persistence Simple, Stupid A possible future for Java - - PowerPoint PPT Presentation

keep persistence simple stupid
SMART_READER_LITE
LIVE PREVIEW

Keep Persistence Simple, Stupid A possible future for Java - - PowerPoint PPT Presentation

Keep Persistence Simple, Stupid A possible future for Java Persistence Robert Brutigam adidas AG The KISS principle. Herbstcampus 2010 Keep Persistence Simple, Stupid 2 Complexity Cost Functions (Lower) Cost (Higher) Complexity


slide-1
SLIDE 1

Keep Persistence Simple, Stupid

A possible future for Java Persistence

Robert Bräutigam

adidas AG

slide-2
SLIDE 2

Herbstcampus 2010 – Keep Persistence Simple, Stupid 2

The KISS principle.

slide-3
SLIDE 3

Herbstcampus 2010 – Keep Persistence Simple, Stupid 3

Complexity – Cost – Functions

(Higher) Complexity (Lower) Cost (More) Functions

slide-4
SLIDE 4

Herbstcampus 2010 – Keep Persistence Simple, Stupid 4

Don’t take my word for it? Trends

“Enterprise Application” Lightweight Waterfall Model Agile S c r u m EJB ORM J 2 E E S p r i n g

slide-5
SLIDE 5

Herbstcampus 2010 – Keep Persistence Simple, Stupid 5

We’re not there! Some current issues.

ORM

slide-6
SLIDE 6

Herbstcampus 2010 – Keep Persistence Simple, Stupid 6

Introducing BeanKeeper

slide-7
SLIDE 7

Herbstcampus 2010 – Keep Persistence Simple, Stupid 7

Getting Started

... <dependency> <groupId>hu.netmind.beankeeper</groupId> <artifactId>beankeeper</artifactId> <version>2.6.3</version> </dependency> ...

// Allocate the "Store" object Store store = new Store("org.postgresql.Driver", "jdbc:postgresql://localhost:5432/test"); // Create the book Book book = new Book("Snow Crash","ISBN"); book.getAuthors().add(new Author("Neal Stephenson")); // Save your first object store.save(book);

slide-8
SLIDE 8

Herbstcampus 2010 – Keep Persistence Simple, Stupid 8

Domain Model Object example

public class Book { private String title; private String isbn; private List<Author> authors; public Book() { } public Book(String title, String isbn) { this.title=title; this.isbn=isbn; authors = new ArrayList(); } // Normal setter/getters ... }

slide-9
SLIDE 9

Herbstcampus 2010 – Keep Persistence Simple, Stupid 9

Store API

// Saving (creating or updating) an object in the database public void save(Object obj); // Removing an object from database public void remove(Object obj); // Getting objects from the store public List find(String statement, Object... parameters); // Getting the lock tracker service public LockTracker getLockTracker(); // Getting the transaction tracker public TransactionTracker getTransactionTracker(); …

slide-10
SLIDE 10

Herbstcampus 2010 – Keep Persistence Simple, Stupid 10

Some possible listing constructs

List<Book> books = (List<Book>) store.find(“find book”); find book where title='Snow Crash' order by title asc find author where book.authors contains author and book.title='Snow Crash' find book where book.mainauthor.name = 'Neil Stephenson' find object find serializable find permission where permission.user.name='Joe' at '2010-06-20' view book.title, book.mainauthor.name where book.publishdate < '2010-06-20'

slide-11
SLIDE 11

Herbstcampus 2010 – Keep Persistence Simple, Stupid 11

A biased comparison BeanKeeper vs. JPA 2.0

slide-12
SLIDE 12

Herbstcampus 2010 – Keep Persistence Simple, Stupid 12

Learning Curve

slide-13
SLIDE 13

Herbstcampus 2010 – Keep Persistence Simple, Stupid 13

Object Lifecycle

slide-14
SLIDE 14

Herbstcampus 2010 – Keep Persistence Simple, Stupid 14

Transparent result list / container paging

// Getting millions of books List<Book> books = (List<Book>) store.find(“find book”); // Process each without any further configuration for ( Book book : books ) process(book); // Getting a service which has millions of events Service service = store.findSingle(“find service where name = ‘Test‘); // Process each event without any further configuration for ( Event event : service.getEvents() ) process(event);

slide-15
SLIDE 15

Herbstcampus 2010 – Keep Persistence Simple, Stupid 15

Low cost transaction isolation

  • 1. Serializable
  • No dirty reads
  • Repeatable result list
  • No phantom reads
  • 2. Repeatable Read
  • No dirty reads
  • Repeatable entities
  • 3. Read Committed
  • No dirty reads
  • 4. Read Uncommitted
slide-16
SLIDE 16

Herbstcampus 2010 – Keep Persistence Simple, Stupid 16

Additional goodies

  • list ordering
  • schema evolution
  • polymorphic pessimistic locking
  • “is null” operator
  • reserved word usage

http://beankeeper.netmind.hu

slide-17
SLIDE 17

Vielen Dank! Robert Bräutigam

adidas AG