File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes what's the relationship between toplink and ejb? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "what Watch "what New topic

what's the relationship between toplink and ejb?

lily luo

Joined: Dec 04, 2001
Posts: 3
what situation does toplink have to be used? in essentional, what's the relationship between toplink and ejb?
John M Brown
Ranch Hand

Joined: Nov 29, 2001
Posts: 62
Toplink is an object to relational mapping tool. When used in an EJB context, a Toplink container replaces the EJB container (at least in Weblogic).
If you are using Toplink, then instead of coding your own JDBC, you would ue their mapping workbnch to map objects and elements to relational database tables and fields. Or you can use Toplink,s API to perform simple to complex queries, inserts, updates, etc. The part I like the most about Toplink is it's flexibility compared to using EJB-QL. You can use aggregate functions such as Sum, Min, Max. It has a mechanism for unique sequence number generation either by using your database's ability to do this, or generically by creating a sequence table. You can drill down to using direct JDBC or SQL statements and stored procedures if you need to.
The two drawbacks with Toplink is that it is a very flexible and powerful tool which can be misused in design, which can result in performance problems with your application. You almost need a specialist, group, or role that is mainly for managing, deploying, and tuning it. Particularly someone who has a good DBA understanding and good knowledge of OOD. The other "drawback" is that it does add about 15% overhead if used without any specialized tuning. This is more of a potential drawback if you consider that if you don't use Toplink, a lot of the things it handles (object/relational mapping, caching, transactional integrity when using BMP Entity beans) will probably have to be done in your code and design.
The biggest advantage to using toplink comes when your data model and/or design changes. Unless you have used more native techniques (like prepared SQL and stored procedures), you do not have to change any code. Just bring up the Mapping workbench, remap the objects to the data, and redeploy. Toplink's mapping uses XML that gets packages with the EJBs. The JDBC (or SQL) is generated based on the mappings dynamically at runtime. Toplink can be configured to log the SQL in the application server log for testing and debug.
Another good advantage it has is when you have objects within objects that have to be loaded. Toplink can be configured to retreive the objects that are referenced in another object all in one transaction, or as needed (using a lazy instantiation pattern). This also works with inherited objects. Of course, here is where you want to be careful with your design as far as performance.
I've not used any other object to relational mapping tools, but we had evaluated Toplink when doing an extensve evaluation of Application servers, and decided that it was a tool worth adding to our development/production setup.
Oh another note. The licensing for toplink is only based on development. The production part of toplink can be distributed to as many production servers as you want at no cost. I know that the Wegain product comes with toplink for it's professional version. Sold alone there was a minimum of 3 developer licence requirement when we were looking at it. If you are considering using WebGain, then it's cheaper to buy Webgain professional, unless you can work out a deal with toplink.
Hope that helps

<a href="" rel="nofollow"></a>
mukund kulkarni

Joined: Nov 11, 2001
Posts: 23
toplink is OR mapping tool.
it maps the relational database tables with the toplink classes and handles the transaction , relatation-ship management issues.
you can use either toplink (OR mapping tool) or EJB's.
TOplink is more suitable for more complex relational databse table handling.


-Mukund Kulkarni<br /> <br />Sun Certified Java Programmer<br />Sun Certified Java Developer
I agree. Here's the link:
subject: what's the relationship between toplink and ejb?
jQuery in Action, 3rd edition