Showing posts with label Spring-Roo. Show all posts
Showing posts with label Spring-Roo. Show all posts

Spring Roo with MySQL (DB Reverse Engineering)

  • Be Noted: all the tables in the given schema, their primary key need to be auto_increment.
  • create project weddingMySQLRE 
  • persistence setup --provider HIBERNATE --database MYSQL --databaseName guestdb --userName root --password secret
  • change <property name="hibernate.hbm2ddl.auto" value="create"/> to <property name="hibernate.hbm2ddl.auto" value="update"/> in /src/main/resources/META-INF/persistence.xml
  • database introspect --schema guestdb 
  1. Located add-on that may offer this JDBC driver 
  2. 1 found, sorted by rank; T = trusted developer; R = Roo 1.1 compatible 
  • addon install id --searchResultId 01
  • database introspect --schema guestdb
  • database reverse engineer --schema guestdb --package ~.domain
  • controller all --package ~.web
  • add weddingMySQLRE project into server, and start server
  • http://localhost:8080/weddingMySQLRE
Thoughts: It's a little bit difficult to do DBRE on oracle, that's because Spring Roo does not provide OSGi drivers for Oracle and DB2. So we have to either obtain an OSGi-enabled driver or wrap the 
driver using Roo's wrapping facility. See the following links to see how to do it:

http://saber.b2b2000.com/display/BLUE/2011/01/26/Roo+reverse+engineering+on+Oracle

Spring Roo Flex Using Existing Oracle Database

  • create new Root project: Project name: weddingFlex; Top Level: com.wedding
  • open roo shell
  • persistence setup --provider HIBERNATE --database ORACLE --databaseName XE --userName practice_db --password secret 
  • change <property name="hibernate.hbm2ddl.auto" value="create"/> to <property name="hibernate.hbm2ddl.auto" value="update"/> in /src/main/resources/META-INF/persistence.xml
  • flex setup
  • entity --class ~.domain.Rsvp
  • field string code --notNull --sizeMin 1 --sizeMax 30
  • field string email --sizeMax 30
  • field number attending --type java.lang.Integer
  • field string specialRequests --sizeMax 100
  • field date confirmed --type java.util.Date
  • flex remoting all --package ~.service
  • add weddingFlex project into server, and start server
  • http://localhost:8080/weddingFlex/weddingFlex_scaffold.html

Spring Roo Using Existing Oracle Database

I have tested this in both Spring Roo 1.1.1 and 1.1.4.
  • create new Root project: Project name: wedding2; Top Level: com.wedding
  • open roo shell
  • persistence setup --provider HIBERNATE --database ORACLE --databaseName XE --userName practice_db --password secret 
  • change <property name="hibernate.hbm2ddl.auto" value="create"/> to <property name="hibernate.hbm2ddl.auto" value="update"/> in /src/main/resources/META-INF/persistence.xml
  • entity --class ~.domain.Rsvp
  • field string code --notNull --sizeMin 1 --sizeMax 30
  • field string email --sizeMax 30
  • field number attending --type java.lang.Integer
  • field string specialRequests --sizeMax 100
  • field date confirmed --type java.util.Date
  • controller scaffold ~.web.RsvpController
  • add wedding2 project into server, and start server
  • http://localhost:8080/wedding2

Spring Roo Notes without Flex

We are going do this from STS based on this
This is the most simple version:
  • create new Root project: Project name: wedding; Top Level: com.wedding
  • open roo shell
  • persistence setup --provider HIBERNATE --database ORACLE --databaseName XE --userName practice_db --password secret 
  • entity --class ~.domain.Rsvp
  • field string code --notNull --sizeMin 1 --sizeMax 30
  • field string email --sizeMax 30
  • field number attending --type java.lang.Integer
  • field string specialRequests --sizeMax 100
  • field date confirmed --type java.util.Date
  • controller scaffold ~.web.RsvpController
  • add wedding project into server, and start server
  • http://localhost:8080/wedding

Spring-Flex-Addon: using existing database

Here is a good link
  1. persistence setup --provider HIBERNATE --database ORACLE --databaseName XE --userName practice_db --password secret 
  2. comment out <property name="hibernate.hbm2ddl.auto" value="create"/> in /TestRoo/src/main/resources/META-INF/persistence.xml 
  3. flex setup 
  4. entity --class ~.domain.Toy --identifierField id --identifierColumn ID --table Toy 
  5. field string DESCRIPTION --notNull 
  6. field string MANUFACTER 
  7. field number version --type java.lang.Integer 
  8. flex remoting all --package ~.service
problem is flex remoting all --package ~.service, at this step, Toy.as is not created.

The workaround is:
shutdown roo at this point, and manually create Toy.as.

Well, still not work, first, wipe all the existing data, second, could not add new entry from GUI.

The complete notes to use Spring-Flex Addon (4)

If there is any problem.

You might need add the following into pom.xml

The complete notes to use Spring-Flex Addon (3)

Use STS sts-2.6.0.SR1 + Flash Builder 4.5

Be Noted: STS has to be 32 bit.

  • Install Flash Builder 4.5 (there is no plugin version now.)
  • Run C:\Program Files (x86)\Adobe\Adobe Flash Builder 4.5\utilities\Adobe Flash Builder 4.5 Plug-in Utility.exe
  • Choose C:\springsource\sts-2.6.0.SR1 as Eclipse folder
Now open STS, now you should have Flash View.
  • Make sure 1.6 Java SDK as the default JRE
  • Make sure using Roo 1.1.1.RELEASE
  • New->Spring Roo project
  • Project name: election 2012, Top level package name: com.hempire
  • Maven support: Dependency management only
  • Click Finish
  • Open Roo Shell
  • persistence setup --provider HIBERNATE --database ORACLE --databaseName XE --userName practice_db --password secret
  • flex setup
  • entity --class ~.domain.Candidate --testAutomatically
  • field string name --notNull
  • flex remoting all --package ~.service
Open servers View, select SpringSource tc Server, right click, Add and Remove, add election2012 project.
start the server.
Select election2012 project, right click, Run As, Web Application. Application will open.

The complete notes to use Spring-Flex Addon (2)

From command line
  • mkdir eclection2012
  • cd eclection 2012
  • roo
  • project --topLevelPackage com.hempire --projectName election2012
  • persistence setup --provider HIBERNATE --database ORACLE --databaseName XE --userName practice_db --password secret
  • flex setup
  • entity --class ~.domain.Candidate --testAutomatically
  • field string name --notNull
  • flex remoting all --package ~.service
  • exit
  • mvn compile
  • mvn tomcat:run
  • http://localhost:8080/election2012/election2012_scaffold.html

The complete notes to use Spring-Flex Addon (1)

Prerequisites:
1. Java JDK 1.6 (I suppose 1.5 is OK too).
2. Maven 2.09 or above.
3. Install ojdbc jars
mvn install:install-file -Dfile=C:\bea\weblogic92\server\lib\ojdbc14.jar -DgroupId=com.oracle -DartifactId=ojdbc14 -Dversion=10.2.0.2 -Dpackaging=jar -DgeneratePom=true

mvn install:install-file -Dfile=C:\bea\wlserver_10.3\server\lib\ojdbc6.jar -Dpackaging=jar -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.1.0

4. Set up spring-roo with spring-flex-addonWe have 2 options here.
a. Spring Roo 1.1.0.M1 + Spring-Flex-Addon-1.0.0.M1
  • put org.springframework.flex.roo.addon-1.0.0.M1.jar under C:\springsource\spring-roo-1.1.0.M1\bundle
  • C:\springsource\spring-roo-1.1.0.M1\bin in PATH
b. Spring Roo 1.1.1.RELEASE + Spring-Flex-Addon-1.0.0.BUILD
  • put org.springframework.flex.roo.addon-1.0.0.BUILD-20110219.075648-225.jar under C:\springsource\spring-roo-1.1.1.RELEASE\bundle
  • C:\springsource\spring-roo-1.1.1.RELEASE\bin in PATH
We will use option b, since the new versions of STS are only compatible with Spring Roo 1.1.1.RELEASE.

5. Setup database
  • SQL> connect
  • Enter user-name: system
  • Enter password:
  • Connected.
  • SQL> create user practice_db identified by secret;
  • User created.
  • SQL> grant dba to practice_db;
  • Grant succeeded.

Spring Roo and Spring Flex Addon

According to link, there are 2 combinations that are working so far.

a. Spring-flex-1.5.0.M1 release (org.springframework.flex.roo.addon-1.0.0.M1.jar) is only compatible with spring-roo-1.1.0.M1 and STS 2.3.3.M1.
b. There is a patch (org.springframework.flex.roo.addon-1.0.0.BUILD-20110219.075648-225.jar), which will work with Spring-roo-1.1.1.Release.

Spring-flex-1.5.0.M1 release is the only release so far which contains Spring Flex Addon.
The good thing is the latest STS (Version: 2.6.0.RELEASE) is compatible with Spring-roo-1.1.1.Release, this will give us all the three featrues:
a. the most updated STS
b. Spring Roo
c. Flex Addon for Spring Roo

Be noted, if you want to option b, which probably most of us will do, you need manually add the following lines to pom.xml
Introducint Flex Addon for Spring Roo
Flex Spring Forum
STS with Flash Builder Plugin
Getting Started With Spring Roo