use of io.crnk.jpa.query.JpaQueryFactoryContext 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.jpa.query.JpaQueryFactoryContext 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