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:
(See https://jira.springsource.org/browse/ROO-1133)
Add the following to src/main/resources/META-INF/spring/applicationContext.xml
<bean id=”passwordEncoder” class=”org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder”>
<constructor-arg value=”MD5″ />
</bean>

Add the following to the Users class:
@Autowired
@Transient
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;
}

One Reply to “Using Roo on an existing database”

Leave a Reply

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