Hi Tim,
Looks good!
For those not familiar with the EclipseLink OSGi proof of concept
you may be wondering where this version of createEntityManagerFactory
comes from? Well I think I just gave it away, but it's a method on
org.eclipse.persistence.jpa.osgi.PersistenceProvider. If you're not
using the proof of concept then, well, nevermind. ;-)
Shaun
Tim Hollosy wrote:
Thanks I'm in business now :) , except I couldn't use the static
persistence class, instead I did it this way:
emf = new PersistenceProvider().createEntityManagerFactory("pu-name",properties,MyClass.class.getClassLoader());
On Tue, Apr 8, 2008 at 10:40 AM, Shaun Smith <shaun.smith@xxxxxxxxxx> wrote:
Here's a code snippet for using a Derby DataSource. There's no connection
info in the persistence.xml in this sample.
--Shaun
private DataSource createDataSource() {
/**
* <property name="eclipselink.jdbc.url"
value="jdbc:derby://localhost:1527/sample;create=true"/>
* <property name="eclipselink.jdbc.user" value="app"/>
* <property name="eclipselink.jdbc.password" value="app"/>
*/
ClientDataSource dataSource = new ClientDataSource();
dataSource.setServerName("localhost");
dataSource.setPortNumber(1527);
dataSource.setDatabaseName("sample");
dataSource.setUser("app");
dataSource.setPassword("app");
return dataSource;
}
private EntityManagerFactory getEntityManagerFactory() {
if (emf == null) {
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PersistenceUnitProperties.NON_JTA_DATASOURCE,
createDataSource());
emf = Persistence.createEntityManagerFactory(PU_NAME,
properties);
}
return emf;
}
natjohns wrote:
I did this, but I just used the Spring framework to set up JPA and my old
DAOs and datasources. You would just follow the examples on the Spring
website, or one of Shauwn's or Doug's Blogs had some good example too.
Nate
Tim Hollosy wrote:
I'm attempting to get EclipseLink to play nice with an existing DAO
(J2SE project),
and I'd like to have reuse an existing JDBC Datasource rather than
configuring EclipseLink to connect itself. Is this possible? I don't
see anything obvious in the API.
Thanks!
--
./tch
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
--
Shaun Smith | Principal Product Manager, TopLink | +1.905.502.3094
Oracle Fusion Middleware
110 Matheson Boulevard West, Suite 100
Mississauga, Ontario, Canada L5R 3P4
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
--
Shaun Smith | Principal Product Manager, TopLink |
+1.905.502.3094
Oracle Fusion Middleware
110 Matheson Boulevard West, Suite 100
Mississauga, Ontario, Canada L5R 3P4
|