SpringSource in 2008 (now part of Pivotal) – Taught Spring in over 20 countries ▪ Core-Spring, Spring MVC, Spring with JPA/Hibernate – Based in Singapore In charge of the Spring Petclinic sample app Blog: https://spring.io/team/misvy/ twitter: @michaelisvy
VisitRepository JdbcVisitRepository JpaVisitRepo SpringDataJpa VisitRepo findByPetId: 16 lines of code Based on Spring’s JdbcTemplate findByPetId: 6 (short) lines of code findByPetId: 0 lines (interface declaration is enough based on naming conventions)
extends Repository<User, Long> { <S extends User> save(S entity); // Definition as per CRUDRepository User findById(long i); // Query determined from method name User findByNameIgnoreCase(String name); // Case insensitive search @Query("select u from User u where u.emailAddress = ?1") User findByEmail(String email); // ?1 replaced by method param }
AOer startup Interface UserRepository Interface UserRepository $Proxy1 implements You can conveniently use Spring to inject a dependency of type UserRepository. Implementation will be generated at startup time <jpa:repositories base-package="com.acme.repository"/>
more appropriate? 19 public class UserController extends SimpleFormController { public ModelAndView onSubmit(Object command) { //... } } @Controller public class UserController { @RequestMapping(value="/users/", method=RequestMethod.POST) public ModelAndView createUser(User user) { //... } } Deprecated!!
contains custom tags <html xmlns:custom="urn:jsptagdir:/WEB-INF/tags/html" …> … <custom:inputField name="firstName" label="Enter your first name:" /> <custom:inputField name=”lastName" label="Enter your last name:" /> </html> JSP file 1 line of code instead of 9!! No more JSP soup!