Search in sources :

Example 1 with LocalEntityManagerFactoryBean

use of org.springframework.orm.jpa.LocalEntityManagerFactoryBean in project camel by apache.

the class JpaEndpoint method createEntityManagerFactory.

protected EntityManagerFactory createEntityManagerFactory() {
    LocalEntityManagerFactoryBean emfBean = new LocalEntityManagerFactoryBean();
    emfBean.setPersistenceUnitName(persistenceUnit);
    emfBean.setJpaPropertyMap(getEntityManagerProperties());
    emfBean.afterPropertiesSet();
    return emfBean.getObject();
}
Also used : LocalEntityManagerFactoryBean(org.springframework.orm.jpa.LocalEntityManagerFactoryBean)

Example 2 with LocalEntityManagerFactoryBean

use of org.springframework.orm.jpa.LocalEntityManagerFactoryBean in project camel by apache.

the class JpaRouteSharedEntityManagerTest method getBrokerCount.

private int getBrokerCount() {
    LocalEntityManagerFactoryBean entityManagerFactory = applicationContext.getBean("&entityManagerFactory", LocalEntityManagerFactoryBean.class);
    //uses Spring EL so we don't need to reference the classes
    StandardEvaluationContext context = new StandardEvaluationContext(entityManagerFactory);
    context.setBeanResolver(new BeanFactoryResolver(applicationContext));
    SpelExpressionParser parser = new SpelExpressionParser();
    Expression expression = parser.parseExpression("nativeEntityManagerFactory.brokerFactory.openBrokers");
    List<?> brokers = expression.getValue(context, List.class);
    return brokers.size();
}
Also used : BeanFactoryResolver(org.springframework.context.expression.BeanFactoryResolver) StandardEvaluationContext(org.springframework.expression.spel.support.StandardEvaluationContext) SpelExpressionParser(org.springframework.expression.spel.standard.SpelExpressionParser) Expression(org.springframework.expression.Expression) LocalEntityManagerFactoryBean(org.springframework.orm.jpa.LocalEntityManagerFactoryBean)

Aggregations

LocalEntityManagerFactoryBean (org.springframework.orm.jpa.LocalEntityManagerFactoryBean)2 BeanFactoryResolver (org.springframework.context.expression.BeanFactoryResolver)1 Expression (org.springframework.expression.Expression)1 SpelExpressionParser (org.springframework.expression.spel.standard.SpelExpressionParser)1 StandardEvaluationContext (org.springframework.expression.spel.support.StandardEvaluationContext)1