Giter Site home page Giter Site logo

employee-crud-demo's Introduction

Commit Versions:

v1: Use EntityManager but leverage native Hibernate API

v2: Use EntityManager and standard JPA API

v3: Spring Data JPA

v2 Insights: Benefits of JPA, JPA vs Native Hibernate Methods

Benefits

  • By having a standard API, you are not locked to vendor's implementation
  • Maintain portable, flexible code
  • Can theoretically switch vendor implementations
  • If vendor ABC stops supporting their product, switch to vendor XYZ without vendor lock in

Comparison

  • Create/save new entity:

    Native Hibernate method: session.save()

    JPA method: entityManager.persist()

  • Retrieve entity by id

    Native Hibernate method: session.get()/load()

    JPA method: entityManager.find()

  • Retrieve list of entities

    Native Hibernate method: session.createQuery()

    JPA method: entityManager.createQuery()

  • Save or update entity

    Native Hibernate method: session.saveOrUpdate()

    JPA method: entityManager.merge()

  • Delete entity

    Native Hibernate method: session.delete()

    JPA method: entityManager.remove()

v3 Insights: Benefits of Spring Data JPA, JpaRepository

Benefits

  • Create a DAO and just plug in your entity type and primary key
  • Spring will give you CRUD implementation for FREE ... like MAGIC!!
  • Helps to minimize boiler-plate DAO code (Approx. more than 70%).

JpaRepository

  • Spring Data JPA provides the interface: JpaRepository.
  • Exposes methods (some by inheritance by parents).
  • Methods: findAll(), findById(id), save(entity), deleteById(id), others...

Advanced Features

  • Extending and adding custom queries with JPQL.
  • Query Domain Specific Language (Query DSL)
  • Defining custom methods (low-level coding)

employee-crud-demo's People

Contributors

azhar-azad avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.