The docs for the EntityManager say, that setDatasource() on an Ejb3Configuration is ignored outside an ApplicationServer, which means that this:
Code:
Ejb3Configuration cfg = new Ejb3Configuration();
cfg.addProperties(hibernateProperties);
cfg.addAnnotatedClass(Customer.class);
cfg.addAnnotatedClass(Address.class);
cfg.addAnnotatedClass(OrderProcess.class);
cfg.setDataSource(dataSource);
silently fails outside an app-server.
I'm trying to use the EntityManager outside an appserver and have configured DataSources via Spring using
Code:
<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="txDataSource"/>
</bean>
So, two questions:
- I am outside of an appserver, but I have a DataSource - how can I teach hibernate to use the supplied DataSource?
- can I trick Hibernate to think that its inside an Appserver? Or more precise, how does hibernate determine if it lives inside an Appserver?
At least a message, that the setDataSource() is ignored would be nice - right now the method fails silently. It would be nice to add a warning...
cheers
stf