Primefaces, Hibernate and SpringRoo Integration With Example

SpringRoo is an open source software tool that uses convention-over-configuration concept to facilitate producing Java-Based enterprise software application in a driven command-line way. We’ve introduced set of tutorials that get you around creating an enterprise application. Primefaces, Spring Framework, Hibernate, EclipseLink and a different kinds of data stores are combined selectively to help you creating an enterprise application.

This tutorial is different, that is you won’t develop any layers you’ve got developed before. Everything would be assigned for SpringRoo and you will learn the required integration and commands that help you get your first application installed and running.

Final Project Structure


Required Tools

  • SpringRoo 1.2.5
  • JDK 1.6+
  • Apache Tomcat 7
  • Maven 2+
  • Eclipse Kepler 4.3
  • MySQL 5.x

Eclipse Spring Roo Integration

To integrate your Eclipse IDE with a SpringRoo software you have to follow below steps carefully:

  • Download SpringRoo software into your local directory and unzip. For clarification purpose, we’ve unzipped it into D:SpringRoospring-roo-1.2.5.RELEASE.
  • Install SpringRoo plugin into your Eclipse IDE. This is can be done by going into Help – Install New Software and type this given into your Work with address input.
  • SpringRoo-Install-New-Software-Fetch-All-Plugins
  • Check both of Core/Spring IDE and Extensions / Spring IDE.
  • SpringRoo-Install-New-Software-Install-Required-SpringRoo-Software
  •   Click Next and finish and wait till the installation process finished.
  • SpringRoo-Installing-New-Software
  • Make sure you are restarted your Eclipse IDE. In case you’ve installed Spring Roo successfully, then you are about getting welcome screen like below.
  • Eclipse-IDE-Integrated-With-SpringRoo-1024x544
  • From Project Explorer, create a new Project and select Spring Roo Project.
  • Click next and type Primefaces-SpringRoo-Hibernate-Sample into Project name. Name your Top level package name and make sure your Project type is standard.
  • Create-New-Spring-Roo-Project-Filling-in-Required-Info
  • Click on Configure Roo Installations and Add your downloaded Spring Roo library.
  • Configure-Spring-Roo


  • Make sure you are selecting a WAR packaging way. Click next and Finish. SpringRoo will start building up your Project using the information you provide.
  • Once SpringRoo Project created, you must notice that a SpringRoo Shell Command – Plugin Shell – is opened. In case you’ve faced some obstacles in getting it started and ready, just restart your eclipse and activate the SpringRoo shell once again by clicking on Open Roo Shell for projects.
  • Now, you are ready to start building up your project.

Database View

SpringRoo has facilitated a known paradigm for getting your JPA entities ready for use at a glance. Your Database’s Tables can be reversed engineered in order to eliminate the need of getting additional commands executed. So let’s see what’s the business Tables we’re truly want to implement.


In general, we have two Tables; Employee and Phone which are associated in a One-To-Many associa
tion type. Phone Table contains a foreign key refers employeeId field in Employee Table. Following below required SQL create scripts.



Developing SpringRoo Application

Developing an enterprise application using a SpringRoo software does contain executing of more than one command against SpringRoo shell. Following a clarified steps for creating wanted application.

  • Setup used persistence framework by executing persistence setup --database MYSQL --provider HIBERNATE --hostName localhost --userName root --password root --databaseName journaldev --persistenceUnit hibernate.jpa
  • Setup-Persistence-Layer-Hibernate
  • Install MySQL driver, that would help your SpringRoo software to load the required driver when the process of reverse engineering get started. We have a MySQL driver located on D:mysql-connector-java-5.1.18-bin.jar. Executing of osgi install --url file:\D:mysql-connector-java-5.1.18-bin.jar would be fair enough. In case you’ve missed out executing this instruction you will get JDBC driver not available for ‘com.mysql.jdbc.Driver’ message when it comes to connect your MySQL database for reverse engineering phase.
  • Create JPA entities, SpringRoo provides you an easy way to create your entities. By executing database reverse engineer --schema journaldev  --package --disableVersionFields --activeRecord true --disableGeneratedIdentifiers SpringRoo will scan your database and creating the entities by reversing defined Tables there.
  • Create-Entities-1024x292
  • Create Primefaces Web layer, one of the options that SpringRoo provides is creating the presentation layer using a JSF implementation. Executing of web jsf setup --implementation ORACLE_MOJARRA --library PRIMEFACES --theme BLUESKY will create all required files for your presentation tier including of required forms like: Employee Registration, Phone Registration, Manage Employees and Manage Phones.
  • Table-Design-Diagram
  • Create all web stuffs, including utilities beans, required managed beans, converters, messages etc. Executing of web jsf all --package ~.web will help you create all of these stuffs.
  • Create-Managed-Beans-Converters-Utilities-and-All-web-stuffs-1024x412
  • For avoiding identifier generation exception, open Employee_Roo_Jpa_Entity.aj and Phone_Roo_Jpa_Entity.aj using Eclipse CTRL+SHIFT+R like below:
  • Editing-Entities-Using-Eclipse
  • Add @GeneratedValue(strategy=GenerationType.Auto) annotation onto both of Employee’s identifier and Phone’s identifier.



  • Execute mvn clean package in order to generate some Java files required by SpringRoo AspectJ does generates and to generate the required WAR for next coming deployment task.
  • Copy your generated WAR file into Apache Tomcat home/webapp folder.
  • Deploy-SpringRoo-Application-Into-Your-Apache-Tomcat-1024x555
  • Start up your Apache Tomcat and type the given URL that’s shown below.
  • Home-Page-1024x552


Now, you have started your Apache Tomcat and you are staying on the home page for the SpringRoo application. As you’ve noticed, four forms are developed automatically; Create Employee, Create Phone, List All Employees and List All Phones. Let’s take a look before getting started creating new employees and phones.



Persisted Records

Now, let’s see the records that are persisted into your MySQL database.



SpringRoo has used for Rapid Application Development (RAD), it’s used conventionally for developing an enterprise application in which a Hibernate is the persistence layer and the Primefaces is the presentation layer. Contribute us by commenting below and find downloaded source code.

By admin

Leave a Reply

%d bloggers like this: