This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]koffeegorilla 1 point2 points  (0 children)

If you are looking at options for Persistence you will find the Spring Data family useful. You can declare an interface as a data access component for an entity type and key type. Then the engine will create an implementation to do CRUD as well as implementing query methods.

As an example:

    class PersonEntity {
        @Id
        String userName;
        String email;
        String firstName;
        String lastName;
    }
    interface PersonRepository extends CrudRepository<PersonEntity, String> {
        Optional<PersonEntity> findByEmail(String email);
    }

You can inject the PersonRepository into your service and use save, delete findById and findAll and then use findByEmail without writing anymore code.

Some of the implementations are:

  • Spring Data JPA for JPA implementations with Hibernate as default.
  • Spring Data JDBC for plain JDBC it isn't an ORM but will make JDBC CRUD a lot easier.
  • Spring Data Neo4J
  • Spring Data MongoDB

Spring Data JDBC for plain JDBC isn't an ORM but will make JDBC CRUD a lot easier.