On Tue, Nov 20, 2012 at 4:27 AM, Jay Walters <jaymwalt...@verizon.net> 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 >
Hi I think LocalContainerEntityManagerFactoryBean is meant for people using Spring XML style. At least Spring has this concept for xxxFactoryBean to turn XML into a bean. You can configure the Camel Jpa component directly in Java code. I assume there may be some examples in the unit test of camel-jpa itself. https://svn.apache.org/repos/asf/camel/trunk/components/camel-jpa/ -- Claus Ibsen ----------------- Red Hat, Inc. FuseSource is now part of Red Hat Email: cib...@redhat.com Web: http://fusesource.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen