Twitter

joi, 11 august 2016

Hibernate JPA sync/async transactions JUnit tests for MySQL and PostgreSQL

Inspired from Hibernate Master Class by Vlad Mihalcea (author of  High-Performance Java Persistence book, repo: GitHub) I wrote a simple application that can be use to test transactions for MySQL and PostgreSQL. Basically, the application uses Hibernate JPA and you can easily:

  • select between MySQL and PostgreSQL
  • configure data source via a properties file (samples provided)
  • specify if the data source should be proxied by ttddyy/datasource-proxy
  • specify if you want to use the HikariCP
  • specify the pool size for HikariCP (default to 3, if 0 is set)
  • specify a custom interceptor
  • test simple transactions
  • test sync transactions
  • test sync transactions by scheduling the nested one (unfortunately because JUnit kill child threads, this works by blocking the main thread - not so useful)
  • test async transactions via a fixed (specified size) thread pool
  • execute code before/after the transaction by overriding a built-in functional interface
  • count executed statements via db-util
  • auto-detects your entities (annotated with @Entity) by scanning /target folders
Well, I've done this app for playing with it, but maybe you will find something useful in it also. Here it is. By default, it contains 8 tests for MySQL, and 2 should fail with an javax.persistence.OptimisticLockingException exception.

Niciun comentariu:

Trimiteți un comentariu