DAL4j Framework Generated Pojo Example
This project found in the samples/framework directory, demonstrates how to generate and interact with Entity beans generated by the FrameworkPojoGenerator class. The generated Entities are DAL4j framework enabled entities but can also behave like normal Entity beans that do not interact with the DAL4j framework.
Framework genreated pojos can interact the the DAL4j framework to simplify/abstract common operations. See samples/framework/src/com/dal4j/sample/framework/app/TestApp.java for more detail.
Pojo Generation
This project comes with pre-generated Entity beans which can be found in the src/com/dal4j/sample/framework/ejb/entity directory. To re-generate these classes (to undersand how code generation works) do the following.
NOTE: To perform code generation a MySQL or SQLServer database server is required. 1. Create the sample database, see README.txt in the samples/db directory. 2. Edit the appropriate configuration file found in samples/framework/bin: config-sqlserver.xml - If the sample DB is in a sqlserver database. config-mysql.xml - If the sample DB is in a mysql database. In the configuration file, url, user, pwd, and instance as needed: 3. From samples/framework in a dos or unix shell run from the bin directory: DOS: classgen <appropriate-config-file.xml> Unix/Cygwin: classgen.sh appropriate-config-file.xml For a SQL server database. classgen.sh config-sqlserver.xml For a MySQL server database. classgen config-mysql.xml 4. If the command worked, the code was generated to src/com/dal4j/sample/framework/ejb/entity 5. Edit META-INF/persistence.xml with your database connection information. In persistence.xml,change the following as required to connect to you database: <property name="eclipselink.jdbc.driver" value="net.sourceforge.jtds.jdbc.Driver"/> <property name="eclipselink.jdbc.url" value="jdbc:jtds:sqlserver://localhost:1433;databaseName=dal4j"/> <property name="eclipselink.jdbc.password" value="dal4j"/> <property name="eclipselink.jdbc.user" value="dal4j"/> 6. Re-compile the code, from the samples/framework directory, run: ant NOTE: Ant must be in your path for this to work. 7. At this points, tests can be executed... See 'Test Execution'
Test Execution
To run the test applicationl, run the following command from the
samples/framework/bin directory:
DOS: run Unix/Cygwin: run.sh