Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2006

Tip: Looking for answers? Try searching our database.

Reducing code of ResultSet DTOs

Thread view: 
Alex - 07 Apr 2006 17:30 GMT
Hi Everyone,

I'm new to Java. I'm writing an app in Struts and am transferring data from
the database to the view layer. My DTOs that I create are more of a mundane
exercise. (getters and setters) Is there a dynamic way of creating
DTOs/JavaBeans?

Thanks!
Alex - 07 Apr 2006 17:42 GMT
> Hi Everyone,
>
[quoted text clipped - 4 lines]
>
> Thanks!

Actually, to clear up my post, I've read that the most common way to return
values from a database is to iterate through a ResultSet and creating an
object that holds a copy of the data of each row. Then placing the objects
in a collection. What happens when you're returning a table of 20 or 30
columns. That's quite a bit of typing. Is there a simplier way to do this?
James McGill - 07 Apr 2006 17:53 GMT
> Is there a simplier way to do this?

http://www.hibernate.org

http://java.sun.com/blueprints/patterns/DAO.html

http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html

http://www.castor.org/
john gresh - 07 Apr 2006 17:58 GMT
You could write a code generator that reads the data dictionary of the
database (eg all_tables, all_tab_columns, etc. in oracle) and generates
the appropriate .java file for a specified table or collection of
tables.
James McGill - 07 Apr 2006 17:46 GMT
> Is there a dynamic way of creating
> DTOs/JavaBeans?  

I use Castor.  While it's not a JAXB implementation, it has a builder
that will create your DTOs by parsing an XML schema.  

For DAO, I then just write hibernate mappings for these objects.  We
have a custom doclet for doing this but I don't use it.  It's too easy
just to do it, the automation becomes an extra layer of complexity that
we don't need.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.