Your SlideShare is downloading. ×
0
HadesOliver Gierke - Synyx GmbH & Co. KG
„Simple things should be simple, complex things should be possible.“
Alan Kay
www.devoxx.com
Speaker
■ Oliver Gierke - gierke@synyx.de
■ Software Architect @ Synyx GmbH & Co. KG
■ JavaEE, Spring (beyo...
Java Persistence API
www.devoxx.com
GenericDao
GenericJpaDao
CRUD
www.devoxx.com
Demo I
Query methods
www.devoxx.com
1. Create interface
2. Declare methods
3. Tune queries
www.devoxx.com
GenericDao UserDao
GenericJpaDao
CRUD Query methods
GenericDaoFactory /
GenericDaoFactoryBean
Derive
User findByUsername(
String username);
Named Query
@NamedQuery
(name=“User.findByLastname“
query=“...“)
List<User> findByLastname(...);
@Query
@Query(„from User u where ...“)
List<User> findByLastname(...);
www.devoxx.com
Demo II
Pagination
Sorting
@Query(„from User u where
u.lastname = ?“)
Page<User> findByLastname(
String lastname,
Pageable pageable);
@Param(„name“)
@Query(„from User u where
u.lastname = :lastname
or u.firstname = :firstname“)
List<User> findByLastOrFirstname(
@Param(„l...
@Modifying
@Modifying
@Query(„...“)
int undefaultAllBut(Role role);
Spring
integration
<hades:dao-config
base-package=“foo.**.dao“ />
Spring IDE Plugin
Custom
DAO code
www.devoxx.com
GenericDao UserDao UserDaoCustom
GenericJpaDao UserDaoImpl
CRUD Query methods
Custom
implementation
Generic...
www.devoxx.com
Demo III
Additional
support
Auditing
Created? Modified?
Who? When?
Domain base
classes
Questions?
WTF
www.devoxx.com
Meta stuff
■ Current version: 1.0 (stable 1.1-snapshot)
■ Apache license 2.0
■ http://hades.synyx.org
Generic DAOs With Hades
Upcoming SlideShare
Loading in...5
×

Generic DAOs With Hades

3,641

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
3,641
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
60
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Transcript of "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
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×