i am really weired about the Toplink API and how to use it.
Until now, i used the JPA Implementation from Toplink (with an Entity Manager). My (far far away) Finish is a little Online-Offline WebStart client with DataSync mechanism.
For this Reason i search the web a littlebit and foud some manuals about the "Toplink API", which in my understanding offers a little bit more functionality then the JPA defaults (in fact the "UnitOfWork" seems pretty nice for my application).
Here my "old" EntityManager Project (which connects to the Offline = local Derby-DB), which i want to rebuild with the Toplink API instead.
and a little CodeSnipped:
** works fins **
now i try to build up the connection with the Toplink API instead, but i am too stupid i think ;) Same datasource as above
Error says, that he can't found the datasource and no default driver???
In Toplink Manual i read in addition somethink about the a project.xml, which can be used to read all the configuration aboute the connection from a xml file:
but a) the "XMLProjectReader" seems not be present for toplink-essentials and b) i find nowhere a documentation how to build up such a project.xml
Maybe i am running in the complete wrong direction, hope somebody could show me the right way ;)
In your login you need to call, setConnectionString, not setDatabaseURL.
TopLink Essentials does not support the project.xml, but if you upgrade to EclipseLink (TopLink 11g), everything is supported.
In general I would recommend using JPA, not the native TopLink API. You can still use JPA and access the UnitOfWork API when required. You can get a UnitOfWork from an EntityManager, or create one from an EntityManagerFactory's ServerSession.
James Sutherland wrote: You can get a UnitOfWork from an EntityManager
I found the "getActiveSession()" from EntityManager, this seems to be the best way, but my Problem is that i use the EntityManager (as shown above) from javax.persistence.Persistence; . The additional functions to get the active Session and aquire a unit of work just seems to be present for the entitymanager from Toplink self. The Problem is to get an Toplink-Entitymanager, i need the Factory, the Toplink-EntityManagerFactory need a ServerSession to create, and i am at the same position as above . Or is there any opportunity to get the Session/UoW from the javax.persistence.Persistence.EntityManager; or "convert" this EntityManager in a Toplink-One?
Thanks a lot
Joined: Oct 01, 2007
You can just cast the EntityManager interface to the EclipseLink/TopLink JpaEntityManager. If using JEE, you will need to first call getDelegate().