Generic DAOs With Hades
-
Author
oliver-gierke -
Category
Technology
-
view
3.525 -
download
3
Embed Size (px)
description
Transcript of Generic DAOs With Hades

HadesOliver Gierke - Synyx GmbH & Co. KG
„Simple things should be simple, complex things should be possible.“Alan Kay

www.devoxx.com
Speaker
■ Oliver Gierke - [email protected]
■ Software Architect @ Synyx GmbH & Co. KG
■ JavaEE, Spring (beyond the obvious)
■ Financial industry, automotive
■ Hades project lead
■ olivergierke

Java Persistence API


Query methods

www.devoxx.com
1. Create interface2. Declare methods3. 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(...);

PaginationSorting

@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(„lastname“) String lname,@Param(„firstname“) String fname)

@Modifying

@[email protected](„...“)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 Customimplementation
GenericDaoFactory /GenericDaoFactoryBean

Additionalsupport

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