An open API service indexing awesome lists of open source software.

https://github.com/yangboz/guice-repository

Automatically exported from code.google.com/p/guice-repository
https://github.com/yangboz/guice-repository

Last synced: 6 months ago
JSON representation

Automatically exported from code.google.com/p/guice-repository

Awesome Lists containing this project

README

          

Overview

Guice-repository is a Guice-adapted version of spring-data-jpa project with some additional features.

Theory can be found here:
- http://martinfowler.com/eaaCatalog/repository.html
- http://msdn.microsoft.com/en-us/library/ff649690.aspx
- http://design-pattern.ru/patterns/repository.html

Features:

- Full support of original 1.1-1.4, 2.2-2.5 spring-data-jpa documentation parts;
- Support of original 2.6, 2.7 parts in manual programmatic Spring wiring mode;
- Support for batch store (see SimpleBatchStoreJpaRepository);
- Full support for @Transactional methods for all Guice-instantiated entities (NEW in 2.0);
- Support for multiple persistence units (NEW in 2.0);
- Support for direct injection of EntityManager/EntityManagerFactory with @PersistenceContext/@PersistenceUnit/@Inject&@Named annotations (NEW in 2.0);
- Support for injections in repositories/custom implementations (NEW in 2.0);
- PersistFilter as implementation of "Open EntityManager in View"/"session-in-view"/"session-per-http-request" pattern (NEW in 2.0);
- More natural way of Repository binding process (NEW in 2.0);
- Auto-binder possibilities with exclusion/inclusion filters - see ScanningJpaRepositoryModule (filters is NEW in 2.0);
- Ability to bind interceptor to catch Repository methods with @Transactional (NEW in 2.0);
- Significant performance improvements (NEW in 2.0);
- Support for all settable properties of JpaRepositoryFactoryBean: namedQueries & queryLookupStrategyKey (see RepositoryBindingBuilder) (NEW in 2.0);
- Allow access to EntityManager (see EntityManagerProvider);
- Significant test coverage.

Quickstart

1. Define your Repository interface
public interface AccountRepository extends JpaRepository,
EntityManagerProvider {

Account findAccountByUuid(String uuid);

@Query("select a from Account a where a.name = :name")
Account findAccountByName(@Param("name") String name);
}

2. Install a Guice-module
install(new JpaRepositoryModule("my-persistence-unit") {
@Override
protected void bindRepositories(RepositoryBinder binder) {
binder.bind(AccountRepository.class).to("my-persistence-unit");
}
});

3. @Inject & use
public class AccountService {

@Inject
private AccountRepository accountRepository;

public void registerUser(String login, String password) throws RegistrationException{
// ... some checks & etc
accountRepository.save(new Account(login, password));
// ... something else
}

public Account findAccount(String login) throws FinderException{
return accountRepository.findAccountByLogin(login);
}
}

Project on google-code:
http://code.google.com/p/guice-repository/

Project documentation:
http://code.google.com/p/guice-repository/wiki/DevGuide