Problems with CASTOR?
One should note that the CASTOR framework is not an
implementation of SUN JDO specification. CASTOR is, however, one
of the very widely used open source or frameworks. I have found
it to be very stable. At least I have not found any open
source(free) O/R mapping frameworks that are easier to use and
more stable than CASTOR as of writing this article.
Some other points to note are some limitations of CASTOR as
published here in this article. But the only limitations
that really stand out of this article are:
- Castor may not have some of the best error messages: This
seems to be more of a matter of gaining more experience with the
framework.
- It may not be the best framework for complex object
relationships with multiple level of dependencies: Although I
have not verified this, even if this is true, the simplicity and
robustness CASTOR provides out weighs this.
One possible solution could be, use CASTOR for its simplicity
and get a working code very fast, to start with. As your
application grows if you identify any cases where CASTOR is
inadequate or inefficient, you can bypass its use only for
those cases. Please look at the
open stack project for more details and examples of an
adapter framework that lets you choose the type of data access
framework dynamically. Specifically the project page
provides links to architecture document code and API docs, that
illustrate this.
Conclusion:
In the last article we used pure JDBC for database access from
STRUTS. In this article we used CASTOR JDO for the same. There
are a few important points to note:
- We used a connection pooled data source with CASTOR and
specified the O/R mapping in the mapping.xml file. We
demonstrated how this file could be autogenerated.
- We discussed use of CASTOR from a STRUTS application.
- As mentioned earlier if you ever face a need to use plain
JDBC for certain calls , where CASTOR can not provide the
required functionality; look at the Adapter example provided at
The open stack project page.
Browse through the Architecture , Java Doc or sample
code
Finally I would like to thank Srinivas Sethuraman of The Open Stack project for providing a starting point for this. You can look at his starting docs for an example of test client, caching and also an example on relationships amongst tables. His docs can be found here.
Harshal Deo
has 10 years of experience working with
enterprise systems. He has worked with companies like
Citicorp & KPMG and currently works for an enterprise
software company Asera. Previously he has worked with
a valley startup MHP, as a lead Architect, defining
the application architecture of its J2EE based system.
He has also published a few articles on technology and
related areas.
Harshal is also one of the founders of
www.theopenstack.com--an online community,
simplifying and promoting the use of open source
technologies for enterprise application development.
New on the Java Boutique:
New Review:
Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling
API boasts simplicity, ease-of-integration, a well-rounded feature
set, and it's free!
New Applet:
Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA
sequences into three useful formats.
Elsewhere on internet.com:
WebDeveloper Java
Lots of Java information on webdeveloper.com
WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.
ScriptSearch Java
Hundreds of free Java code files to download.
jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.