Raible's Wiki

Raible Designs
Wiki Home
News
Recent Changes

AppFuse

Homepage
  - Korean
  - Chinese
  - Italian
  - Japanese

QuickStart Guide
  - Chinese
  - French
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish
  - Japanese

User Guide
  - Korean
  - Chinese

Tutorials
  - Chinese
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish

FAQ
  - Korean

Latest Downloads

Other Applications

Struts Resume
Security Example
Struts Menu

Set your name in
UserPreferences


Referenced by
Articles
Articles_pt
CreateDAO_es
CreateDAO_pt
CreateDAO_sp
CreateDAOiBATIS
CreateManager
CreateManager_es
CreateManager_ko
CreateManager_zh
...and 3 more




JSPWiki v2.2.33

[RSS]


Hide Menu

CreateDAO


This is version 42. It is not the current version, and thus it cannot be edited.
[Back to current version]   [Restore this version]


Part I: Creating new DAOs and Objects in AppFuse - A HowTo for creating Java Objects (that represent tables) and creating Java classes to persist those objects in the database.

About this Tutorial

This tutorial will show you how to create a new table in the database, and how to create Java code to access this table.

We will create an object and then some more classes to persist (save/retrieve/delete) that object from the database. In Java speak, we call the object a Plain Old Java Object (a.k.a. a POJO). This object basically represents a database table. The other classes will be:

  • A Data Access Object (a.k.a. a DAO), an Interface and a Hibernate Implementation
  • A JUnit class to test our DAO is working

AppFuse uses Hibernate for it's persistence layer. Hibernate is an Object/Relational (O/R) Framework that allows you to relate your Java Objects to database tables. It allows you to very easily perform CRUD (Create, Retrieve, Update, Delete) on your objects.

You can also use iBATIS as a persistence framework option. To install iBATIS in AppFuse, view the README.txt in contrib/ibatis. If you're using iBATIS over Hibernate, I expect you have your reasons and are familiar with the framework. I also expect that you can figure out how to adapt this tutorial to work with iBATIS.
I will tell you how I do stuff in the Real World in text like this.

Let's get started on creating a new Object, DAO and Test in AppFuse's architecture.

Table of Contents

  • [1] Create a new Object and add XDoclet tags
  • [2] Create a new database table from the object using Ant
  • [3] Create a new DaoTest to run JUnit tests on the DAO
  • [4] Create a new DAO to perform CRUD on the object
  • [5] Configure Spring for the Person object and PersonDao
  • [6] Run the DaoTest

Create a new Object and add XDoclet tags [#1]

The first thing we need to do is create an object to persist. Let's create a simple



Go to top   More info...   Attach file...
This particular version was published on 06-Nov-2006 13:52:30 MST by 192.35.84.5.