use of io.crnk.jpa.util.SpringTransactionRunner in project crnk-framework by crnk-project.
the class AbstractJpaJerseyTest method tearDown.
@Override
@After
public void tearDown() throws Exception {
super.tearDown();
SpringTransactionRunner transactionRunner = context.getBean(SpringTransactionRunner.class);
transactionRunner.doInTransaction(new Callable<Object>() {
@Override
public Object call() throws Exception {
EntityManager em = context.getBean(EntityManagerProducer.class).getEntityManager();
AbstractJpaTest.clear(em);
return null;
}
});
if (context != null) {
context.destroy();
}
}
use of io.crnk.jpa.util.SpringTransactionRunner in project crnk-framework by crnk-project.
the class CustomResourceFieldTest method setup.
@Override
@Before
public void setup() {
super.setup();
SpringTransactionRunner transactionRunner = context.getBean(SpringTransactionRunner.class);
transactionRunner.doInTransaction(new Callable<Object>() {
@Override
public Object call() throws Exception {
EntityManager em = context.getBean(EntityManagerProducer.class).getEntityManager();
AbstractJpaTest.clear(em);
LangEntity en = new LangEntity();
en.setLangCd("en");
em.persist(en);
LangEntity de = new LangEntity();
de.setLangCd("de");
em.persist(de);
CountryEntity ch = new CountryEntity();
ch.setCountryCd("ch");
ch.setCtlActCd(true);
em.persist(ch);
CountryTranslationEntity chDe = new CountryTranslationEntity();
CountryTranslationPK chDePk = new CountryTranslationPK();
chDePk.setCountry(ch);
chDePk.setLang(de);
chDe.setCountryTranslationPk(chDePk);
chDe.setTxt("Schweiz");
em.persist(chDe);
CountryTranslationEntity chEn = new CountryTranslationEntity();
CountryTranslationPK chEnPk = new CountryTranslationPK();
chEnPk.setCountry(ch);
chEnPk.setLang(en);
chEn.setCountryTranslationPk(chEnPk);
chEn.setTxt("Switzerland");
em.persist(chEn);
em.flush();
return null;
}
});
}
Aggregations