use of io.crnk.jpa.meta.internal.JpaMetaEnricher in project crnk-framework by crnk-project.
the class JpaModule method setupModule.
@Override
public void setupModule(ModuleContext context) {
this.context = context;
Set<Class> jpaTypes = new HashSet<>();
if (config != null) {
for (JpaRepositoryConfig<?> config : config.getRepositories()) {
jpaTypes.add(config.getEntityClass());
}
}
jpaMetaProvider = new JpaMetaProvider(jpaTypes);
jpaMetaLookup = new MetaLookup();
jpaMetaLookup.addProvider(jpaMetaProvider);
jpaMetaLookup.setModuleContext(context);
jpaMetaLookup.initialize();
if (config != null) {
initQueryFactory();
}
context.addResourceInformationBuilder(getResourceInformationProvider(context.getPropertiesProvider()));
context.addExceptionMapper(new OptimisticLockExceptionMapper());
context.addExceptionMapper(new PersistenceExceptionMapper(context));
context.addExceptionMapper(new PersistenceRollbackExceptionMapper(context));
addHibernateConstraintViolationExceptionMapper();
addTransactionRollbackExceptionMapper();
context.addRepositoryDecoratorFactory(new JpaRepositoryDecoratorFactory());
if (em != null) {
metaEnricher = new JpaMetaEnricher();
// enrich resource meta model with JPA information where incomplete
MetaModuleExtension metaModuleExtension = new MetaModuleExtension();
metaModuleExtension.addProvider(metaEnricher.getProvider());
context.addExtension(metaModuleExtension);
setupTransactionMgmt();
}
}
Aggregations