Spring roo

Proof-of-Concept Using Spring Roo

by on January 20, 2014 12:00 pm

In my time with Keyhole, I’ve been involved in a number of projects where the client was asking us to rewrite a legacy system while retaining their existing database. Sometimes it helps to give a quick demo on how using current technologies can make it easier to develop, test, and maintain their code.

One way I’ve found to get a quick example created (that is relevant to the project at hand) is to use Spring Roo. Its ability to reverse engineer a data model from an existing database schema certainly comes in handy.

Here are the steps to do this when your client is using an Oracle database:

1. While Spring Roo is accessible with just a command prompt, it’s much easier to use an IDE and the easiest one to use for this task is Spring’s own Eclipse-based IDE, Spring Tool Suite (STS). You can download the latest version from http://spring.io/tools.

STS Download Page

2. Once you’ve downloaded and set up STS, hit Ctrl-N to bring up the New wizard (or you can select File –> New –> Other…). Type “roo” into the filter and select “Spring Roo Project”. Click “Next”.

Spring Roo Project

3. For now, just fill in the first two fields with an appropriate project and package name. The defaults will work for the rest of the fields. Click “Next” again and then click “Finish” to create the new project.

Spring Roo Project wizard
Spring Roo Project wizard finish

4. What should happen is that your project will come up with a view labeled “Roo Shell”. Normally, it hangs trying to open that view. So I close that view, then right-click on your new project and choose “Spring Tools –> Open Roo Shell”. This time it should come up quickly and look like this.

Roo Shell

5. Now we let Roo do its job and lead us down the path to a fully set up project. Go ahead and enter “hint” on the Roo command line. It tells us that we need to set up a persistence configuration, so let’s follow the suggestions it gives us.

Roo Shell hint

6. For this particular example, I’m using an Oracle database with EclipseLink as the persistence provider but there are a number of options and Roo will show them to you when you hit Ctrl-Space at the Roo command prompt.

Roo Shell database setup

7. You’ll see that Oracle has made things a little bit difficult on us by not making the driver publically available. You can learn how to create an OSGI-wrapped version of the Oracle driver that can be installed and used by Roo in a blog post by technical consultant Kerry Wilson at http://www.goodercode.com/wp/spring-roo-database-reverse-engineer-with-oracle/.

Roo Shell database driver

8. Finally, we’re ready for the good part. Enter the command “database reverse engineer –package ~.domain –schema PUBLIC” into the Roo command prompt, where “domain” is the package name where you want your models created and “PUBLIC” is the name of the schema you want to reverse engineer.

9. Roo will do some work and when it’s finished you’ll have POJOs that represent your database tables with JPA annotations for the fields and relationships. If the database is anything more than a very simple model, it’s very likely that Roo got something wrong. However, you did just save yourself hours of creating entities for each table in the schema so you can spend some of that time fixing Roo’s mistakes.

Final Notes

While I’ve only talked about how Roo can be used to map a database schema to a Java entity model, Roo is also useful for getting the initial configuration set up for a number of web technologies. It can create unit tests, add logging, integrate with GWT, JSF, JMS, Solr, Spring MVC, and others. Best part, especially if you aren’t using Roo on the full project, is that all of the Roo annotations can be removed and you’re left with pure Java code that can be the base of your new project.

- Brice McIver, asktheteam@keyholesoftware.com

  • Share:

One Response to “Proof-of-Concept Using Spring Roo”

Leave a Reply

Things Twitter is Talking About
  • #HTML5 is a viable technology for the enterprise & a must-know for single page applications. Learn how - http://t.co/VlOjRiWZ25 #tutorial
    April 24, 2014 at 4:19 PM
  • JSF components can be used to quickly bring up a user interface. Here's a quick example using #ICEFaces: http://t.co/5YCOtIy2HE
    April 24, 2014 at 11:35 AM
  • Signed up for Keyhole's free monthly tech newsletter yet? Latest resources compiled to a quick email. Sign up here: http://t.co/F8h0NSiicZ
    April 24, 2014 at 10:35 AM
  • code smell: dev practices that leave a stench of inexperience. Avoid it in method implementation with these tips - http://t.co/b7A884BnXb
    April 23, 2014 at 9:20 PM
  • Tech Night is now! Mark D is presenting to the group on #Grunt 101. Good technology talk, food & team makes for a fantastic night.
    April 23, 2014 at 5:10 PM
  • Single Page Application architectures allow for rich, responsive UIs. #JavaScript is a must-know for SPA - http://t.co/6sfk3kt1k3 #tutorial
    April 23, 2014 at 2:15 PM
  • Vacuole #Encapsulation aims to minimize the code necessary for routinely verbose data tasks -http://t.co/fJQzz731rZ
    April 23, 2014 at 9:45 AM
  • DYK? We translate our hands-on experience to custom courses to train your dev teams. Our new course on #AngularJS: http://t.co/Bf3UuClj4Z
    April 23, 2014 at 8:45 AM
  • Interested in #Backbone & #Marionette but not sure where to start? Check out the Marionette-Require-Boilerplate: http://t.co/XDj43BwSS3 #SPA
    April 22, 2014 at 4:50 PM
  • Responsive Design can help in giving your users a consistent app experience across devices. Quick tutorial - http://t.co/BDrT5LvgRo
    April 22, 2014 at 2:31 PM
  • Tips & tricks to save time in the #Eclipse IDE - http://t.co/uGgCkchwNk (keystroke combos, navigation, time tracking & more)
    April 22, 2014 at 8:40 AM
  • Join us! Looking to add to our team a developer w/ advanced #JavaScript & #NodeJS exp (& love of tech variety). Info: http://t.co/cC9CU1RCF9
    April 21, 2014 at 7:35 PM
  • Looking into #ExtJS but don't know where to start? Check out our video tutorial series to find your way around - http://t.co/XFYDT6YNWA
    April 21, 2014 at 4:35 PM
  • We've been tinkering with JS library Famo.us since its public release 4/10. What we've learned so far via a POC app - http://t.co/S77TSKHDKd
    April 21, 2014 at 2:03 PM
  • RT @CompSciFact: Rivest, Shamir, and Adleman published the RSA public key cryptography algorithm in 1978.
    April 21, 2014 at 11:13 AM
  • DYK? When we share/RT/blog/etc, it doesn't mean that Keyhole endorses it - we just like variety of opinions! Info: http://t.co/MXhB9lE9tV
    April 19, 2014 at 3:01 PM
  • A huge welcome to Justin Graber who joined the Keyhole team this week!
    April 18, 2014 at 3:25 PM
  • Pssst... @kc_dc early bird pricing ends on Sunday. Shoot us a note if you want to save 10% off of your ticket with our sponsor promo code!
    April 18, 2014 at 2:49 PM
  • Join our team! Looking for a developer w/ advanced #JavaScript & #NodeJS experience (& love of tech variety). Info: http://t.co/cC9CU1RCF9
    April 18, 2014 at 11:21 AM
  • .@befamous has huge potential to make HTML5/JS/CSS web pages feel as native apps. Here's our inital tech takeaways - http://t.co/S77TSKHDKd
    April 18, 2014 at 9:50 AM
Keyhole Software
8900 State Line Road, Suite 455
Leawood, KS 66206
ph: 877-521-7769
© 2013 Keyhole Software, LLC. All rights reserved.