Example of migrating an application from EJB 1/2 to Spring +
Hibernate.
Version history:
0.1 "Legacy" EJB application
0.2 Spring is introduced and used to replace the
stateless session bean
0.3 Hibernate is introduced and used to replace the entity
bean, the whole EJB module now must be removed as it
is empty
There are IntelliJ IDEA and Eclipse project files, so you
should be able to browse the project without building it.
To build and run the application, you have to
0. have Maven 2 and Java 5 or higher
1. download, install and start JBoss application server (I
used version 4.2.0 GA)
2. configure the JBoss deployment directory in person-ear/pom.xml :
/home/thrantal/work/jboss-4.2.0.GA/server/default/deploy/
3. configure the JBoss library locations in
ejb-migration-example/run.bash (which is unix only)
4. Configure the JBoss embedded HSQLDB to run in the mode
accepting remote connections, e.g. in file
/home/work/jboss-4.2.0.GA/server/default/deploy/hsqldb-ds.xml
select
jdbc:hsqldb:hsql://localhost:1701
5. build, deploy and test the application using maven:
cd ejb-migration-example
mvn -Dmaven.test.skip=true clean install # tests require the server to be
mvn test # running, a chicken-egg-problem
You can then insert data to the PersonEntity table by using
the HSQL Database Manger Tool bundled with JBoss
http://docs.jboss.org/jbossas/getting_started/v4/html/dukesbank.html#X-22013
e.g.
INSERT INTO personentity (id, username, lastname, firstname)
SELECT MAX(id) + 1, 'ftest', 'Testing', 'Frank'
FROM personentity;
commit;
SELECT * FROM personentity;
and try searching the data with the command-line Bash
script:
cd ejb-migration-example/
./run.bash Frank
This should find the inserted person and output something
like
PersonEntity:1002, Frank Testing (ftest)