Java Code Examples for org.apache.olingo.odata2.jpa.processor.api.ODataJPAContext#setEntityManagerFactory()

The following examples show how to use org.apache.olingo.odata2.jpa.processor.api.ODataJPAContext#setEntityManagerFactory() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EspmServiceFactory.java    From cloud-espm-v2 with Apache License 2.0 6 votes vote down vote up
@Override
public ODataJPAContext initializeODataJPAContext()
		throws ODataJPARuntimeException {
	ODataJPAContext oDataJPAContext = this.getODataJPAContext();
	EntityManagerFactory emf;
	try {
		emf = JpaEntityManagerFactory.getEntityManagerFactory();
		oDataJPAContext.setEntityManagerFactory(emf);
		oDataJPAContext.setPersistenceUnitName(PERSISTENCE_UNIT_NAME);
		oDataJPAContext.setJPAEdmExtension(new EspmProcessingExtension());
		oDataJPAContext.setJPAEdmMappingModel("EspmEdmMapping.xml");
		return oDataJPAContext;
	} catch (Exception e) {
		throw new ODataRuntimeException(e);
	}

}
 
Example 2
Source File: JPAServiceFactory.java    From lemonaid with MIT License 5 votes vote down vote up
public ODataJPAContext initializeODataJPAContext() throws ODataJPARuntimeException {
	ODataJPAContext oDataJPAContext = getODataJPAContext();

	EntityManagerFactory factory = (EntityManagerFactory) SpringContextsUtil.getBean(ENTITY_MANAGER_FACTORY_ID);

	oDataJPAContext.setEntityManagerFactory(factory);
	oDataJPAContext.setPersistenceUnitName(DEFAULT_ENTITY_UNIT_NAME);
	oDataJPAContext.setJPAEdmExtension(new JPAEdmExtension());
	ODataContextUtil.setODataContext(oDataJPAContext.getODataContext());

	return oDataJPAContext;
}
 
Example 3
Source File: JPAServiceFactory.java    From odata-boilerplate with MIT License 5 votes vote down vote up
@Override
public ODataJPAContext initializeODataJPAContext() throws ODataJPARuntimeException {
	ODataJPAContext oDataJPAContext = getODataJPAContext();

	EntityManagerFactory factory = (EntityManagerFactory) SpringContextsUtil.getBean(ENTITY_MANAGER_FACTORY_ID);

	oDataJPAContext.setEntityManagerFactory(factory);
	oDataJPAContext.setPersistenceUnitName(DEFAULT_ENTITY_UNIT_NAME);
	oDataJPAContext.setJPAEdmExtension(new JPAEdmExtension());
	ODataContextUtil.setODataContext(oDataJPAContext.getODataContext());
	
	return oDataJPAContext;
}
 
Example 4
Source File: JPAReferenceServiceFactory.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public ODataJPAContext initializeODataJPAContext()
    throws ODataJPARuntimeException {
  ODataJPAContext oDataJPAContext = getODataJPAContext();
  oDataJPAContext.setEntityManagerFactory(JPAEntityManagerFactory.getEntityManagerFactory(PUNIT_NAME));
  oDataJPAContext.setPersistenceUnitName(PUNIT_NAME);
  oDataJPAContext.setJPAEdmMappingModel(MAPPING_MODEL);
  oDataJPAContext.setJPAEdmExtension(new SalesOrderProcessingExtension());
  oDataJPAContext.setPageSize(PAGE_SIZE);
  oDataJPAContext.setDefaultNaming(false);
  oDataJPAContext.getODataContext().setDebugMode(true);
  setErrorLevel();
  setOnWriteJPAContent(onDBWriteContent);
  return oDataJPAContext;
}
 
Example 5
Source File: ODataJPACarServiceFactory.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public ODataJPAContext initializeODataJPAContext()
		throws ODataJPARuntimeException {
	ODataJPAContext oDataJPAContext = getODataJPAContext();
	EmfHolder emfHolder = EmfHolder.createInstance();
	oDataJPAContext.setEntityManagerFactory(emfHolder.getEntityManagerFactory());
	oDataJPAContext.setPersistenceUnitName(emfHolder.getPersistenceUnitName());

	oDataJPAContext.setPageSize(PAGE_SIZE);
	setDetailErrors(true);

	return oDataJPAContext;
}
 
Example 6
Source File: PersonsListServiceFactory.java    From cloud-personslist-scenario with Apache License 2.0 5 votes vote down vote up
@Override
public ODataJPAContext initializeODataJPAContext()
		throws ODataJPARuntimeException {
	ODataJPAContext oDataJPAContext = this.getODataJPAContext();
	try {
		EntityManagerFactory emf = JpaEntityManagerFactory
				.getEntityManagerFactory();
		oDataJPAContext.setEntityManagerFactory(emf);
		oDataJPAContext.setPersistenceUnitName(PERSISTENCE_UNIT_NAME);
		return oDataJPAContext;
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
}
 
Example 7
Source File: BenefitsODataServiceFactory.java    From cloud-sfsf-benefits-ext with Apache License 2.0 5 votes vote down vote up
@Override
public ODataJPAContext initializeODataJPAContext() throws ODataJPARuntimeException {
	ODataJPAContext oDataJPAContext = this.getODataJPAContext();
	try {
		oDataJPAContext.setEntityManagerFactory(EntityManagerFactoryProvider.getInstance().getEntityManagerFactory());
		oDataJPAContext.setPersistenceUnitName(PERSISTENCE_UNIT_NAME);
		oDataJPAContext.setJPAEdmExtension(new BenefitsJPAEdmExtension());

		setContextInThreadLocal(oDataJPAContext.getODataContext());
		return oDataJPAContext;
	} catch (Exception e) {
		throw new ODataRuntimeException("Cannot initialize OData JPA Context", e); //$NON-NLS-1$
	}

}