use of io.crnk.meta.provider.MetaPartition in project crnk-framework by crnk-project.
the class AbstractJpaTest method clear.
public static void clear(final EntityManager em, JpaQueryFactory factory) {
factory.initalize(new JpaQueryFactoryContext() {
@Override
public EntityManager getEntityManager() {
return em;
}
@Override
public MetaPartition getMetaPartition() {
JpaMetaProvider jpaMetaProvider = new JpaMetaProvider(em.getEntityManagerFactory());
MetaLookup metaLookup = new MetaLookup();
metaLookup.addProvider(jpaMetaProvider);
metaLookup.initialize();
return jpaMetaProvider.getPartition();
}
});
clear(em, factory.query(OneToOneTestEntity.class).buildExecutor().getResultList());
clear(em, factory.query(ManyToManyTestEntity.class).buildExecutor().getResultList());
clear(em, factory.query(ManyToManyOppositeEntity.class).buildExecutor().getResultList());
clear(em, factory.query(TestSubclassWithSuperclassPk.class).buildExecutor().getResultList());
clear(em, factory.query(RelatedEntity.class).buildExecutor().getResultList());
clear(em, factory.query(TestEntity.class).buildExecutor().getResultList());
clear(em, factory.query(OtherRelatedEntity.class).buildExecutor().getResultList());
clear(em, factory.query(CountryTranslationEntity.class).buildExecutor().getResultList());
clear(em, factory.query(CountryEntity.class).buildExecutor().getResultList());
clear(em, factory.query(LangEntity.class).buildExecutor().getResultList());
clear(em, factory.query(BasicAttributesTestEntity.class).buildExecutor().getResultList());
clear(em, factory.query(RenamedTestEntity.class).buildExecutor().getResultList());
clear(em, factory.query(UuidTestEntity.class).buildExecutor().getResultList());
em.flush();
em.clear();
}
use of io.crnk.meta.provider.MetaPartition in project crnk-framework by crnk-project.
the class JpaModule method initQueryFactory.
private void initQueryFactory() {
JpaQueryFactory queryFactory = config.getQueryFactory();
queryFactory.initalize(new JpaQueryFactoryContext() {
@Override
public EntityManager getEntityManager() {
return em;
}
@Override
public MetaPartition getMetaPartition() {
return jpaMetaProvider.getPartition();
}
});
if (queryFactory instanceof QuerydslQueryFactory) {
QuerydslQueryFactory querydslFactory = (QuerydslQueryFactory) queryFactory;
querydslFactory.addInterceptor(new JpaQuerydslTranslationInterceptor());
}
}
use of io.crnk.meta.provider.MetaPartition in project crnk-framework by crnk-project.
the class AbstractOperationsTest method clear.
public static void clear(final EntityManager em, JpaQueryFactory factory) {
factory.initalize(new JpaQueryFactoryContext() {
@Override
public MetaPartition getMetaPartition() {
MetaLookup metaLookup = new MetaLookup();
JpaMetaProvider metaProvider = new JpaMetaProvider(em.getEntityManagerFactory());
metaLookup.addProvider(metaProvider);
metaLookup.initialize();
return metaProvider.getPartition();
}
@Override
public EntityManager getEntityManager() {
return em;
}
});
clear(em, factory.query(MovieEntity.class).buildExecutor().getResultList());
clear(em, factory.query(PersonEntity.class).buildExecutor().getResultList());
em.flush();
em.clear();
}
Aggregations