Skip to content

jlmc/hibernate-tunings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Performance Note Java Persistence and Hibernate

Performance Facts

JPA vs Hibernate

  • JPA is only a specification. It describes the interfaces that the client operates with and the standard object-relational mapping metadata (annotations, XML).

  • Although it implements the JPA specification, Hibernate retains its native API for both backward compatibility and to accommodate non-standard features.

HOW TO RUN THIS EXAMPLES

1. Postgres Data Base

First off all, we need to create a Postgres database with the name hibernate-tunings in the port 5432. For example, we can use Docker to create that resource:

docker run --name hibernate-tunings \
    -p 5432:5432 \
    -e POSTGRES_USER=postgres \
    -e POSTGRES_PASSWORD=postgres \
    -e POSTGRES_DB=postgresdemos \
    -v $(pwd)"/hibernate-tunings:/var/lib/postgresql/data" -d postgres:11.4

Or, simply run the docker-compose up command, which will raise a database and run the migrations for us:

docker-compose up

2. Run all modules in a single command

To run all modules in a single command, we can execute:

mvn flyway:migrate -pl database-migrations \
 -Dflyway.configFiles=local.conf \
 -Dflyway.locations=filesystem:database-migrations/migration \
&& mvn clean install -pl helpers \
&& mvn clean package

3. Run Step by Step

  1. Run the migrations:
mvn flyway:migrate -pl database-migrations \
 -Dflyway.configFiles=local.conf \
 -Dflyway.locations=filesystem:database-migrations/migration

Or, in alternative:

cd database-migrations
mvn flyway:migrate -Dflyway.configFiles=local.conf
  1. build and run all the examples.
mvn clean install -pl helpers && mvn clean package

AGENDA

  1. Get-Started

    1. logging-sql-statements

    2. schema-management

  2. Connections

    1. Connection Manager
    2. Connection Lifecycle
    3. Hibernate Statistics
  3. Types

    1. jpa-and-hibernate-types
    2. custom-hibernate-types
    3. open source hibernate types
  4. Identifiers

    1. Generating Primary Keys
    2. Identifiers Generators and Natural Keys
    3. Hibernate Sequence Optimizers
  5. JPA Relationships Types

    1. About
    2. Equals and Hashcode methods
    3. OneToMany and ManyToOne
    4. OneToOne Tradicional Bidimentional
    5. OneToOne Unidirectional with MapsId
    6. ManyToMany
    7. ElementCollection
    8. SecondaryTable
  6. Inheritance

    1. SingleTable About
    2. DiscriminatorColumn
    3. JoinedInheritance with JoinTable
  7. Persistence Context and Flushing

    1. PersistenceContext_Flushing
    2. ActionQueue
    3. AUTO FlushModeType
    4. Dirty-Checking
    • all the examples can be found in the module advanced-topics in the package: io.costax.hibernatetunning.persistencecontext
  8. Batching

    1. Bash Updates Batch and Processing
  9. Cache

    1. 1st and 2nd level and query caches
      • 1st level (Persistence Context)
      • 2nd Level
      • Query cache
    2. 2nd level cache in JavaEE Application Server Example with infinispan (cache2ndee project)
  10. Bulk Operations

    1. Bulk Operation examples
  11. Batching of write operations

    1. Batching-of-write-operations examples
  12. Concurrency

    1. Concurrency About
    2. Isolation Issues
    3. Pessimistic Locking
      • LockModeType.PESSIMISTIC_READ
      • LockModeType.PESSIMISTIC_WRITE
    4. Optimistic-locking
      • @Version
      • Force Version Increment
    5. Timeout: javax.persistence.lock.timeout
    6. Deadlocks
  13. Fetching

    1. Query Hint Fetch Size
    2. DTO Pagination
    3. NativeSQL Synchronized Entity Class
    4. Direct Fetching Entities
    5. Fetch Associations
  14. Tips

About

Performance Note Java Persistence and Hibernate

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages