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
- Host: GitHub
- URL: https://github.com/yangboz/guice-repository
- Owner: yangboz
- License: apache-2.0
- Created: 2015-10-27T11:04:54.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-10-27T11:07:28.000Z (almost 10 years ago)
- Last Synced: 2025-02-08T05:17:51.036Z (8 months ago)
- Language: Java
- Size: 742 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README
- Changelog: CHANGELOG
- License: license.txt
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.htmlFeatures:
- 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