| Project Page | Trackers | Forums | Documentation | Browse CVS | Download |

Welcome to the AutoCRUD Project

» Overview

AutoCRUD is a simple Java based framework, that allows you to design a database schema in MySQL, and generate a complete web application to do CRUD (Create, Retrieve, Update and Delete) operations on these tables. It is similar in design to Ruby on Rails (RoR).

AutoCRUD generates a complete ready-to-run web application into a standard Maven2 directory structure. The web application is based on Spring's MVC framework. It can be started using the Maven2 Jetty plugin from the command line. The files are generated using Velocity templates, so you can change the templates if your coding style is different from mine.

Like in RoR, AutoCRUD generates an ActiveRecord subclass for each database table. The subclass provides getters and setters for each of the database columns. The ActiveRecord class is provided as part of the AutoCRUD framework and provides methods to perform CRUD operations. The methods use dynamic JDBC (using Spring JdbcTemplate).

On the controller end, AutoCRUD provides an ActiveController implementation that is a Spring MultiActionController, and generates the edit, list and show JSP files. The JSP files are all JSTL based, so its clean and maintainable. Each table has an associated controller. Different instances are realized through Spring IoC, each controller is an ActiveController but is injected with the appropriate ActiveRecord subclass. This is slightly different from RoR where the Controllers are explicitly generated for each bean.

AutoCRUD will also generate other Spring and web application artefacts, such as the web.xml, a default landing index.jsp page and the DispatcherServlet's configuration file *-servlet.xml. Currently, it generates the web application as part of the same project AutoCRUD lives in. The packaging will be improved in the future so AutoCRUD can be used to generate different web applications.

»Schema design rules

Since everything is generated, we have to follow certain rules when designing our database schema, so its possible for the generator to build the beans and other artifacts. Here they are:

  1. Entities should be represented by singular table names, and these table names must not contain underscores. For example, project, person, etc.
  2. Join tables that join two entities that have a many-to-many or one-to-many relation must contain both entities in its name, separated by underscore. For example, project_person.
  3. All tables must have an id column, whose type must resolve to the Java long type. Currently only MySQL is supported, so it must also be an autoincrement column. For MySQL, the data type that resolves to a long is bigint(20).
  4. Foreign key reference columns should have the entity name followed by _id, for example, person_id. This is not an issue at the moment, but will be once table relationships are supported in the future.

» Status

The following are features I would like to add to AutoCRUD if I ever have the time or the need for them. Currently, I am no longer building database backed apps, but may do so sometime in the future, when I will pick off on this project again.

  • Multiple database support -- I would like to add Oracle and PostgreSQL support, in addition to the MySQL support already present. Ideally, the backend should be switchable through configuration.
  • Support for table relations -- Currently AutoCRUD works against a single table only. I would like to add persistent data structures to model one-to-many, many-to-one and many-to-many relationships, similar to the way RoR does it.
  • Use of standard widgets -- Currently, all the inputs are of type text, but we may want to create/use standard widgets for date fields, multi-value fields, etc. This is also an idea borrowed from RoR.
  • Packaging improvements -- Will be released as its own JAR with possible Maven2 archetype to generate the CRUD application.
  • Replace JDBC with Hibernate -- An earlier version of AutoCRUD, which I never completed, was based on Hibernate as the ORM. I no longer use Hibernate, so this version uses JDBC with Spring JdbcTemplate. It may make switch to using Hibernate for supporting multiple databases.