Using Roo on an existing database

Creating a web application to update an existing database with Roo is extremely simple…

project –topLevelPackage org.cggh.quac –projectName quac –java 6
persistence setup –provider HIBERNATE –database MYSQL –databaseName drupal_users –userName drupal6 –password drupal6
database introspect –schema drupal_users
database reverse engineer –package ~.model –schema drupal_users
controller all –package ~.web

Some notes:
Make sure that the database has foreign keys set up
If you want security then run:
security setup

For password encoding:
Add the following to src/main/resources/META-INF/spring/applicationContext.xml
<bean id=”passwordEncoder” class=””>
<constructor-arg value=”MD5″ />

Add the following to the Users class:
transient private MessageDigestPasswordEncoder passwordEncoder;

private String pass;

public void setPass(String password) {
if(password==null||password.equals(“”)) {
return; //don’t update password if blank is sent
String encodedPassword = passwordEncoder.encodePassword(password, null);
this.pass = encodedPassword;

Join the Conversation

1 Comment

Leave a comment

Your email address will not be published. Required fields are marked *