Created
July 1, 2019 14:40
-
-
Save recursivecodes/5fdb044f1deb6364b7cb22effcafdfc8 to your computer and use it in GitHub Desktop.
UserRepository.java
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
@RequestScoped | |
public class UserRepository { | |
@PersistenceContext | |
private static EntityManager entityManager; | |
@Inject | |
public UserRepository(UserProvider userProvider) { | |
Map<String, Object> configOverrides = new HashMap<String, Object>(); | |
configOverrides.put("hibernate.connection.url", userProvider.getDbUrl()); | |
configOverrides.put("hibernate.connection.username", userProvider.getDbUser()); | |
configOverrides.put("hibernate.connection.password", userProvider.getDbPassword()); | |
EntityManagerFactory emf = Persistence.createEntityManagerFactory("UserPU", configOverrides); | |
entityManager = emf.createEntityManager(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment