Simple JPA is the lightweight Java JPA2.1 framework that simplify the usage of JPA2.1 This framework is mavenized as well. :)
Hibernate 4.3.11.Final
Sample usage with Spring
@Inject
private DefaultRepository repository;
@Inject
private PasswordEncoder passwordEncoder;
@Transactional(readOnly = false)
@Override
public User add(User user) throws UsernameInUsedException {
// simple and strong typing to count where username is user.getUsername()
if(repository.getCount(User_.username, user.getUsername()) != 0) {
throw new UsernameInUsedException("Username " + user.getUsername() + " is in use, please use other username");
}
user.setPassword(passwordEncoder.encodePassword(user.getUsername(), null));
return repository.create(user);
}
Pau Kiat Wee ([email protected])