Wednesday, June 22, 2011

generate database DDL

Roo automatically generates the database but does not provide a DDL. To generate a DDL add the following text to the pom:
<!-- Generate DDL -->
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>hibernate3-maven-plugin</artifactId>
  <version>2.2</version>
  <executions>
<execution>
  <phase>process-classes</phase>
  <goals>
    <goal>hbm2ddl</goal>
  </goals>
</execution>
  </executions>
  <configuration>
<components>
  <component>
    <name>hbm2ddl</name>
    <implementation>jpaconfiguration</implementation>
  </component>
</components>
<componentProperties>
  <propertyfile>src/main/resources/database.properties</propertyfile>
  <persistenceunit>persistenceUnit</persistenceunit>
  <outputfilename>schema.ddl</outputfilename>
  <drop>false</drop>
  <create>true</create>
  <export>false</export>
  <format>true</format>
</componentProperties>
  </configuration>
</plugin>

Friday, June 10, 2011

roo reverse engineer

These are the steps I followed to have roo generate the database entities.
mkdir project
cd project
roo
In roo type the following to create a project along with the persistence layer.
project --topLevelPackage com.tecunhuman.example
persistence setup --provider HIBERNATE --database POSTGRES
exit roo and modify the file "src/main/resources/META-INF/spring/database.properties" to contain the correct information for the database. run roo again and execute:
database reverse engineer --schema schema-name
It will inspect the database and generate the DAO classes.

Thursday, June 9, 2011

Java rooing with xjc

I have been working on web services using java and found some useful tools to speed up development time. I have been using xjc to generate the web resource entities based on the provided schema. This program generates the classes used for the rest service along with the required annotations. Roo is another tool that generates code. It has an option to reverse engineer a database. This allows creating classes with annotations from an existing database. Our stack requires us to use java, spring and hibernate; roo allows creating entities with test in a fraction of the time.

Thursday, June 2, 2011

In the clouds

My blog is now being hosted on the clouds. It was able to migrate by moving the database and content files. I ran into problems with the themes. I had set the default theme in the database to be able to view anything.
I also moved the repository I use to configure my machine into bitbucket. I figured someone might find them useful. I separated part of it into its own project; searchvim is a project I created to make switching between files in vim simple. I tried to simulate a similar behaviour to that of eclipse or intellij. If someone finds it useful or has suggestions let me know.