 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
DartmanX Guest
|
Posted: Tue Mar 29, 2005 4:58 pm Post subject: Newbie: Data Objects and Associated DAOs |
|
|
I'm a relative newbie at this, but I'm looking for an easier way. I'm
using the 1.4.2 SDK (can't upgrade to 1.5).
When I create an object, I always create the object and an associated
DAO to go with it. Here's a quick example:
public class User {
private int userid;
private String username;
private String password;
public int getUserid() {
return this.userid;
}
// remainder of setter and getter functions
}
public class UserDAO extends GenericDatabaseAccess {
public void addItem(User u) {
// Adds a new user to the backend database
}
public void delItem(int key) {
// Delete from the database based on the key
{
public void editItem(User u) {
// Edits an existing record by replacing the existing record
with
// information in the object passed
}
public User getItem(int key) {
// Return a User object based on the key
}
public java.util.LinkedList getAllItems() {
// Return all of the items from the database as a Linked List
of
// User objects
}
}
Since what I've been writing usually has several object types, I'm
interested in finding a quicker way to do the grunt work of creating
the DAOs. And since I'm a newb, I don't know much except basic JDBC and
a free pooled database connection package I've been using.
Any advice, hints, tricks, etc are appreciated.
Jason
|
|
| Back to top |
|
 |
CodeFutures Guest
|
Posted: Wed Mar 30, 2005 8:48 am Post subject: Re: Newbie: Data Objects and Associated DAOs |
|
|
DartmanX wrote:
| Quote: |
Since what I've been writing usually has several object types, I'm
interested in finding a quicker way to do the grunt work of creating
the DAOs. And since I'm a newb, I don't know much except basic JDBC
and
a free pooled database connection package I've been using.
Any advice, hints, tricks, etc are appreciated.
Jason
|
Hello Jason,
The best shortcut is to generate the Java code for DAOs rather than
write them by hand.
FireStorm/DAO is a Java Code Generator that can import existing
database schemas (from a SQL script or from a live JDBC connection) and
can then generate a complete DAO persistence tier.
Check out:
http://www.codefutures.com/products/firestorm/
Regards
PJ Murray
CodeFutures Software - Java Code Generation for Data Persistence
http://www.codefutures.com
|
|
| Back to top |
|
 |
frebe Guest
|
Posted: Wed Mar 30, 2005 4:53 pm Post subject: Re: Newbie: Data Objects and Associated DAOs |
|
|
DartmanX wrote:
| Quote: | Since what I've been writing usually has several object types, I'm
interested in finding a quicker way to do the grunt work of creating
the DAOs. And since I'm a newb, I don't know much except basic JDBC
and
a free pooled database connection package I've been using.
|
Look at http://butler.sourceforge.net. It has a generator that will
generate java classes based on the tables in your schema.
/Fredrik
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|