Created
March 14, 2024 22:33
-
-
Save jeanpierregomez/1bfe049da2ba2d2d2b8035352c2245bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Repository | |
public class JPARepositoryAdapter extends AdapterOperations<User, UserEntity, String, JPARepository> | |
implements UserRepository | |
{ | |
public JPARepositoryAdapter(JPARepository repository, ObjectMapper mapper) { | |
/** | |
* Could be use mapper.mapBuilder if your domain model implement builder pattern | |
* super(repository, mapper, d -> mapper.mapBuilder(d,ObjectModel.ObjectModelBuilder.class).build()); | |
* Or using mapper.map with the class of the object model | |
*/ | |
super(repository, mapper, d -> mapper.map(d, User.class)); | |
} | |
@Override | |
public User getUser(String id) { | |
return this.findById(id); | |
} | |
@Override | |
public User saveUser(User user) { | |
return this.save(user); | |
} | |
@Override | |
public User updateUser(User user) { | |
return this.save(user); | |
} | |
@Override | |
public void deleteUser(String id) { | |
this.repository.deleteById(id); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment