This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Toplink API Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Toplink API" Watch "Toplink API" New topic
Author

Toplink API

Dominik Müller
Ranch Hand

Joined: Apr 28, 2009
Posts: 36
Hi all together,

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.
Entity


My OfflinePU


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 ;)

thanks a lot
Dom
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
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.

TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

"da dom", please check your private messages for an important administrative matter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Dominik Müller
Ranch Hand

Joined: Apr 28, 2009
Posts: 36
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
Dominik
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
You can just cast the EntityManager interface to the EclipseLink/TopLink JpaEntityManager. If using JEE, you will need to first call getDelegate().
 
Don't get me started about those stupid light bulbs.
 
subject: Toplink API
 
Similar Threads
How database info is specfied in persistence.xml
@OneToMany new reference table is generated.
Hibernate dialect
no error but entity is not persisted
JPA not working with EJB3