My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
5MinutesTutorial  
Updated Sep 29, 2007 by sunnyl...@gmail.com

5 Minutes tutorial

Getting started in 5 minutes

Create entity mapping xml file

copy and past the following example, save it as "mytypemap.xml" somewhere in your computer.
<?xml version="1.0" encoding="UTF-8"?>
<map xmlns="http://www.asksunny.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.asksunny.com typeMap.xsd">	
	<entity javaName="Employee" tableName="Employee">
		<property javaName="ssn" columnName="ssn" allowNull="false"
		primaryKey="true" javaType="string" sqlType="CHAR(11)"/> 
		<property javaName="firstName" columnName="First_Name" allowNull="false"
		javaType="String" sqlType="VARCHAR2" length="64"/>	
		<property javaName="lastName" columnName="Last_Name" allowNull="false"
		javaType="String" sqlType="VARCHAR2" length="64"/>			
	</entity>		 
</map>

Modify ANT build file

In Spring-On-Rails
<installation_folder>
, open up build.xml and copy the following example and past it on build.xml, change target name to "myFirstRails" without quote. Modify springOnRailsTask's attribute accordingly.
<target name="onRailsTarget">
	    <taskdef name="springOnRailsTask" 
	    	classname="com.asksunny.springonrails.ant.SpringOnRailsTask">	
	    	<classpath refid="SpringOnRails_lib"></classpath>
	    </taskdef>		
		<springOnRailsTask  
	    	entityMappingLocation = "File_PATH_TO_mytypemap.xml" 
	    	outputPackageName = "your.java.output.package.name.prefix"  
	    	outputDir = "FILE_PATH_WHERE_YOU_WANT_SOURCE_FILE_TO_BE"
	    	projectName= "PICK_YOUR_FAVORITE_PROJECT_NAME_IN_SHORT"
	    	/>	   

</target>

Run ANT build

It is time to see Spring-On-Rails in action now. Change directory to Spring-On-Rails
<installation_folder>
from unix shell/window command shell and run the following command:

UNIX:

$ant myFirstRails

Windows:

>ant.bat myFirstRails

Start up Jetty Web Server

Change directory to your output directory that you specified at step 2. Change directory of your project name (step 2). And run following command.
mvn jetty:run

Please wait until Jetty fully started and proceed to next step.

Try out newly created application with your favirite browser

enter http://localhost:8080/
<your_project_name>
/index.jsp to your browser's address bar. your should be able to see your newly created Java Enterprise Application in a couple seconds.
Now it is time to see what have been generated.
Comment by jsilva.j...@gmail.com, Oct 1, 2007

nice... but why ant?! maybe a better aproach with a script based java code generation built with ruby...

Comment by project member sunnyl...@gmail.com, Oct 1, 2007

Your comment is correct, It will be replaced Maven 2 Archetype. I was so familar with ANT, it takes a little time for me to create Maven 2 Archetype.

Comment by rien.n...@gmail.com, Nov 21, 2007

"string ssn" was generated.

it was compile error source code,

because first character of string was uncapital letter.

SoR version was 1.0.5

Comment by rien.n...@gmail.com, Nov 21, 2007

I think Groovy DSL was better.


Sign in to add a comment
Powered by Google Project Hosting