views:

430

answers:

3

I wander if with a simple Map implementation for plain records its enough.

I want to do it similar to Ror. When you add a field to de table in the database automatically you have access to the field in the Dto.

I don't want to add a field and then have to add the same field to de DTO declaration. It isn't DRY.

+1  A: 

What I think you're looking for a is very lightweight Object Relational Mapping tool?

If you want to roll your own, then there is a tiny example one as part of this article on developerWorks.

You may want to look at any number of others but Hibernate, JPA and JDO are probably the most popular. Prevayler type systems may be what you're looking for. Of course, none of this may not be what you're after. Could you be a little more specific?

jamesh
A: 

Take a look at this: http://code.google.com/p/activejdbc/

ipolevoy
A: 

It depends what you want.

Java is a static language, so you cannot do the RoR ActiveRecord trick where it adds the methods to the class dynamically, unless you want to manipulate the byte code yourself.

This means that you have to declare a mapping somewhere between a java method (getter/setter) and the database table.

You can do code generation of java classes based upon tables, maybe this is what you want?

MatthieuF