That did the trick. Thanks.
 

On 11/20/12, Babak Vahdat wrote:

Hi

You get null as Spring does one step more than you, that's:

 emFactory.afterPropertiesSet();

Because "LocalContainerEntityManagerFactoryBean implements InitializingBean"

Look at the last line in that method where this FactoryBean does:

 this.entityManagerFactory =
createEntityManagerFactoryProxy(this.nativeEntityManagerFactory);

So maybe calling this method inside your Java code right after emFactory
instantiation could help to move one step further.

Babak


Jay Walters wrote
> My reading of the spring xml makes me think java such as shown below will
> configure the EntityManagerFactory
> 
> JpaVendorAdapter jpaAdapter = new HibernateJpaVendorAdapter();
> BasicDataSource dataSource = new BasicDataSource();
> 
> dataSource.setDriverClassName("org.apache.derby.jdbc.EmbeddedDriver");
> dataSource.setUrl("jdbc:derby:target/test/database;create=true");
> 
> LocalContainerEntityManagerFactoryBean emFactory = new
> LocalContainerEntityManagerFactoryBean();
> emFactory.setPersistenceUnitName("bam");
> emFactory.setJpaVendorAdapter(jpaAdapter);
> emFactory.setDataSource(dataSource);
> 
> emFactory.setPersistenceXmlLocation("/dev/camel-play/persistence.xml");
> JpaTemplate jpaTemplate = new JpaTemplate();
> jpaTemplate.setEntityManagerFactory(emFactory.getObject());
> 
> But the last line fails as emFactory.getObject() is null. I get no debug
> messages, no exception, just a nice fat null.
> 
> In production I might be able to use spring to define this database bit
> since that will be static for the application, and then define
> the routes dynamically with java DSL, but I'd like to have a java example
> without spring if I can get such a thing working.
> 
> Thanks
> Jay





--
View this message in context: 
http://camel.465427.n5.nabble.com/Follow-on-to-configuring-persistence-with-java-not-spring-xml-tp5722984p5723026.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to