Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Introduction to Spring Data Greg Turnquist @gregturn [email protected] github.com/gregturn
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ It’s 2015 Why are we still writing stuff like…
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ It’s 2015 Why are we still writing stuff like… select * from person where person.first_name = %1
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ With Spring Data, you don’t have to!
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ SQL JPL HQL EJBQL CQL CQRS Mongo Query Language ????
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Declaring Repositories 5 public interface PersonRepository extends CrudRepository<Person, Long> { // This interface and a “Person” class is // ALL YOU NEED! }
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Not quite enough? 9 public interface CoolPersonRepo extends CrudRepository<Person, Long> { @Query("select u from User u where u.emailAddress = ?1”) User myCoolCustomQuery(String e) @Query("select u from User u where u.firstname = :firstname”) User findByFirstname(@Param("firstname") String f) @Query("select u from #{#entityName} u where u.lastname = ?1”) List<User> findByLastname(String lastname) List<Person> findAll(Specification spec) }
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ What else? § Repository solutions are VERY handy, but not always enough. § Each data store has a custom template • JpaTemplate • MongoTemplate • Neo4jTemplate • RedisTemplate • ….and so forth 10
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Nice JPA stuff, but what about MongoDB, …? § Spring Data supports • JPA • MongoDB • Neo4j • GemFire a.k.a. Apache Geode • Cassandra • Couchbase • Apache Solr • Elasticsearch • Amazon DynamoDB • (Redis is coming) • ….and ANY repository-based data store 11
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Check it out! 12 Visit http://projects.spring.io/spring-data/
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Introduction to Spring Data Greg Turnquist @gregturn [email protected] github.com/gregturn