Created
January 30, 2016 23:54
-
-
Save VineetReynolds/b37947ed7188a73bd863 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
@Stateless | |
public class Accounts { | |
@PersistenceContext | |
private EntityManager em; | |
... | |
public Account getLiabilitiesAccount() { | |
TypedQuery<Account> findByNameQuery = em.createQuery("SELECT DISTINCT a FROM Account a " | |
+ "WHERE UPPER(a.name) = 'LIABILITIES'", Account.class); | |
Account liabiltiesAccount = findByNameQuery.getSingleResult(); | |
return liabiltiesAccount; | |
} | |
... | |
} |
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
@Stateless | |
public class CustomerAccounts { | |
@PersistenceContext | |
private EntityManager em; | |
@Inject | |
private Accounts accounts; | |
... | |
public CustomerAccount create(String name, Money openingBalance) { | |
Account liabilitiesAccount = accounts.getLiabilitiesAccount(); | |
... | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment