Installing the Code Generator

The Code generator is used to generate annotated Entity Beans from the Database schema.

1. Move the code generator files into the working directory

Firstly you have to move the files from the codegen subdirectory into your working directory.

This includes...

codegen.properties properties file to configure the code generation
codegen.bat batch file to run the code generator
setclasspath.bat batch file to help build the classpath
beanGenerator.vm Velocity template for Beans
embeddedIdGenerator.vm Velocity template for EmbeddedId Beans

2. Edit codegen.bat file

To run the codegen.bat we need to configure the classpath. To do this there are two parameters which point to two directories which can contain jar files.

All the jar files in these directories will be put into the classpath using the setclasspath.bat file.

Configure the JARLIB_DIR1 & JARLIB_DIR2 parameters.


set JARLIB_DIR1=webapp\WEB-INF\lib
set JARLIB_DIR2=lib

REM   Comment out JARLIB_DIR2 if all your jars 
REM   are in a single directory

3. Edit the codegen.properties

You should probably look at all the properties but take special note of these ones


#
# Need generate mode to create files
# test mode will not create any files
#
#ebean.codegen.mode=generate
ebean.codegen.mode=test

#
# The source code directory
#
ebean.codegen.source.directory=c:/devjava/project/appZsite/src

#
# The java package name for the generated beans
#
ebean.codegen.javapackage=app.data.test

#
# patterns for database dictionary loading
# by default loads all tables into the dictionary
#
#ebean.codegen.catalog
#ebean.codegen.schema
#ebean.codegen.table=b_%


4. run codegen.bat from a command line

And you should see something like this....



C:\devjava\project\appZSite>codegen
----------------------------------
CLASSPATH = .;webapp\WEB-INF\lib\avajeCodeGen.jar;webapp\WEB-INF\lib\avajeEbean.jar;...
----------------------------------
 INFO: Ebean Version[0.9.0-061028] Java Version[1.5.0_03]
 INFO: DataSourcePool [mysql] autoCommit[false] transIsolation[READ_COMMITTED] min[1] max[25]
 INFO: DataSourcePool [mysql] grow pool;  busy[0] size[0] max[25]
 INFO: IoRepository initialised dirs[C:/devjava/project/appzsite/webapp/WEB-INF/data] zips[]
 INFO: DictionaryInfo deserialized from file -
 [C:/devjava/project/appzsite/webapp/WEB-INF/data\primarydatabase.dictionary]
 INFO: Plugin[][com.avaje.ebean.server.plugin.MySqlPlugin]
 INFO: VelocityManager initialising
 INFO: Dictionary registering [null][null][null]
==================================================
Generate:
==================================================
BugAttachment                  property   [abstract] uses java reserved word. Set to [summary]
Role                           OneToOne   RoleTest test
Role                           ManyToMany tables s_role to s_user via s_user_role
Role                           ManyToMany User users
User                           ManyToMany tables s_user to s_role via s_user_role
User                           ManyToMany Role roles
RoleTest                       OneToOne   Role role
==================================================
Summary:
==================================================


Matched:
-------------------------------------
UserPreferenceId
UserPreference
BugType
Topic
UserStatus
Comment
BugStatus
Forum
Product
BugAttachment
RoleModuleId
RoleModule
Role
BugDetail
CommentLink
Bug
TopicPost
User
RoleTest
BugPriority
Module
UserLog
TopicType

Lookup:
-------------------------------------

Hairy:
-------------------------------------

Intersection:
-------------------------------------
s_user_role

==================================================
 INFO: Stopping []
 INFO: ThreadPool [TransactionManager] Shutting down; threadCount[1] busyCount[0]
 INFO: DataSourcePool [mysql] shutdown
 INFO: Closing Connection[mysql.1] psReuse[0] psCreate[0] psSize[0]
C:\devjava\project\appZSite>


Introduction User Guide (pdf) Install/Configure Public JavaDoc Whitepapers
General Database Specific Byte Code Deployment Annotations Features
Top Bugs Top Enhancements
woResponse