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


Difference between version 133 and version 132:

At line 184 changed 1 line.
As part of 1.6.1, I created an __AppGen__ tool that can be used to generate all the classes for the rest of these tutorials. This tool was based on contributions from [Lance Lavandowska|https://appfuse.dev.java.net/issues/show_bug.cgi?id=60] and [Ben Gill|https://appfuse.dev.java.net/issues/show_bug.cgi?id=78]. At first, I didn't want to add a code-generation feature like this b/c you'd end up with a 1-to-1 relationship between tables/pojos, DAOs and Managers. On most of my projects, I have far fewer DAOs and Managers than POJOs.
AppFuse versions 1.6.1+ contain include an [AppGen] tool that can be used to generate all the classes for the rest of these tutorials. However, it's best that you go through these tutorials before using this tool - then you'll know what code it's generating.</div>
At line 186 removed 14 lines.
By default, AppGen will generate only Actions/Controllers, Action/Controller Tests, test data, i18n keys and JSPs. It will also configure Actions/Controllers for you. It uses the generic BaseManager and BaseDaoHibernate classes (configured as "manager" and "dao") to reduce the number of files that are generated. However, I realize that sometimes you will want to generate all the DAO and Manager classes (as well as their tests), so I've added that option too.
To use the AppGen tool (after installing your web framework), perform the following steps:
# Create your POJO (in the model directory) and <a href="#ref-CreateDAO-5">configure the mapping file</a> in {{applicationContext-hibernate.xml}}.
# cd into the ''{{extras/appgen}}'' directory and run __ant -Dobject.name=Person -Dappgen.type=pojo__. In this example, the __Person__ class should exist in your {{model}} package. This generates all the files you create in the tutorials on this site (for your chosen web framework).
# To install the generated files, run __ant install__. You can run __ant install -Dmodel.name=Person -Dmodel.name.lowercase=person__ if you want to do everything in one fell swoop. __WARNING:__ You might want to backup your project before you do this - or at least make sure it's checked into a source code repository. I've tested this code, and I think it works well - but it ''is'' modifying your source tree for you.
The reason for the "lowercase" parameter is to rename the JSPs to begin with a lowercase letter. If I tried to rename them and change the filename programmatically, it took 1MB worth of BSF and Rhino JARs (+5 lines of code) and this just seemed easier. Speaking of JSPs - it's up to you to modify the {{*Form.jsp}} and make it look pretty. This is covered in Step 5 of each respective web framework's "Create Action/Controller" tutorial: <a href="http://raibledesigns.com/wiki/Wiki.jsp?page=CreateActions#ref-CreateAction-5">Struts</a>, <a href="http://raibledesigns.com/wiki/Wiki.jsp?page=SpringControllers#ref-SpringControllers-5">Spring</a> and <a href="http://raibledesigns.com/wiki/Wiki.jsp?page=WebWorkActions#ref-WebWorkActions-5">WebWork</a>.
__NOTE:__ If you'd like to generate all the DAOs/Managers/Tests, run __ant install-detailed__ instead of __ant install__. Before you install anything, the files will be created in the {{extras/appgen/build/gen}} directory (in case you want to look at them before installing). If you just want to test the tool, you can cd to this directory and run __ant test__ to see the contents of these tutorials created.
I encourage you to read these tutorials even if you decide to generate all your code. That way you'll understand what's being generated for you and you'll only need to mailing list for [asking smart questions|http://www.catb.org/~esr/faqs/smart-questions.html]. ;-) Hopefully this tool will remove the pain of writing simple CRUD code and let you concentrate on developing your business logic and fancy UIs!</div>

Back to CreateDAO, or to the Page History.