Generic DAOs With Hades

4,167 views

Published on

Slides from the talk on the open source project Hades - http://hades.synyx.org

Published in: Technology, Education
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,167
On SlideShare
0
From Embeds
0
Number of Embeds
297
Actions
Shares
0
Downloads
61
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Generic DAOs With Hades

  1. 1. HadesOliver Gierke - Synyx GmbH & Co. KG „Simple things should be simple, complex things should be possible.“ Alan Kay
  2. 2. www.devoxx.com Speaker ■ Oliver Gierke - gierke@synyx.de ■ Software Architect @ Synyx GmbH & Co. KG ■ JavaEE, Spring (beyond the obvious) ■ Financial industry, automotive ■ Hades project lead ■ olivergierke
  3. 3. Java Persistence API
  4. 4. www.devoxx.com GenericDao GenericJpaDao CRUD
  5. 5. www.devoxx.com Demo I
  6. 6. Query methods
  7. 7. www.devoxx.com 1. Create interface 2. Declare methods 3. Tune queries
  8. 8. www.devoxx.com GenericDao UserDao GenericJpaDao CRUD Query methods GenericDaoFactory / GenericDaoFactoryBean
  9. 9. Derive User findByUsername( String username);
  10. 10. Named Query @NamedQuery (name=“User.findByLastname“ query=“...“) List<User> findByLastname(...);
  11. 11. @Query @Query(„from User u where ...“) List<User> findByLastname(...);
  12. 12. www.devoxx.com Demo II
  13. 13. Pagination Sorting
  14. 14. @Query(„from User u where u.lastname = ?“) Page<User> findByLastname( String lastname, Pageable pageable);
  15. 15. @Param(„name“)
  16. 16. @Query(„from User u where u.lastname = :lastname or u.firstname = :firstname“) List<User> findByLastOrFirstname( @Param(„lastname“) String lname, @Param(„firstname“) String fname)
  17. 17. @Modifying
  18. 18. @Modifying @Query(„...“) int undefaultAllBut(Role role);
  19. 19. Spring integration
  20. 20. <hades:dao-config base-package=“foo.**.dao“ />
  21. 21. Spring IDE Plugin
  22. 22. Custom DAO code
  23. 23. www.devoxx.com GenericDao UserDao UserDaoCustom GenericJpaDao UserDaoImpl CRUD Query methods Custom implementation GenericDaoFactory / GenericDaoFactoryBean
  24. 24. www.devoxx.com Demo III
  25. 25. Additional support
  26. 26. Auditing
  27. 27. Created? Modified? Who? When?
  28. 28. Domain base classes
  29. 29. Questions? WTF
  30. 30. www.devoxx.com Meta stuff ■ Current version: 1.0 (stable 1.1-snapshot) ■ Apache license 2.0 ■ http://hades.synyx.org

×