I, for one, would recommend an EJB solution w/ JBoss if you're going for a
full object model of the database.  There are a couple of ways of migrating
to EJB, but any of them are going to involve some work and learning a little
about EJB containers  and JNDI.  There is a learning curve, but I thought
the EJB model to be relatively easy to learn myself.

Going EJB can slow an application down, it's true, but it all depends on
your situation.  If you have a small application with a low number of users,
the overhead of EJB may negatively impact performance versus a non-EJB
solution.  However, for large applications/large number of concurrent users,
you can't beat JBoss for its thread-pooling, object caching, transaction
management, and other wonderful capabilities.

A large amount of the slow-down people report with EJB is due to heavy use
of Entity beans (the components that form the object data model in EJB),
particularly using many fine-grained Entity objects to model the data.  This
is bad, since retrieving even a small data-set requires the instantiation of
many objects, which obviously slows down performance.  Many people do not
use Entity beans at all, preferring to employ Stateless Session beans (which
have great performance) to execute SQL statements to grab data and return
values, or populate serializable value objects with the data and return
those instead.

If you wanted a (relatively) quick solution, you could use Container Managed
Persistence (CMP) Entity beans to model the data you already have in tables.
Each Entity Class would have field names that correspond to the columns in
your table, with corresponding setXXX() and getXXX() methods in the Entity
Class.  You could then configure the EJB and JBoss deployment descriptors to
use your pre-existing database and table names, and JBoss would take care of
loading/storing data between the Entity bean and the database.  This
approach would assume that you wish a 1-to-1 mapping between tables and
object types in your system.  Check out the JBoss mail list archives for
postings by people who have attempted this, as I'm sure there are some
"gotchas" involved.

Since you already appear to have some value objects created, you could go
with the Bean Managed Persistence (BMP) route, which means your Session
beans would execute SQL statements against your database, and use the
results to populate value objects, which are returned to the front-end parts
of your application. The Session beans could also have methods that accept
these value objects as parameters, for adding new rows or updating all data
for a row in your table.  You can, of course, have single-value setXXX() and
getXXX() methods too, backed by SQL statements.  This approach involves more
custom coding than CMP, but you can manage the data model however you like
and directly control when and how objects are instantiated.


happy coding,

Joe Barefoot


-----Original Message-----
From: James A. Hillyerd [mailto:[EMAIL PROTECTED]]
Sent: Saturday, March 23, 2002 2:15 AM
To: Struts Users Mailing List
Subject: Object Mapping w/ Struts?


I am looking for an object-mapping (to sql relational DB) solution for
Struts.

I have a medium sized database application which I've developed in
struts.  (around 25 tables in PostgreSQL)  I've been using a home-brew
lightweight data-access bean system -- using perl scripts to generate
beans that interact with the database.  The java source these scripts
generate need a lot of manual editing, so making changes to the object
model can be a nightmare.

I tried downloading Torque 2.1, but had problems, so then I tried Torque
3.0b1.  It seems like Torque isn't going to integrate well with my
already existing tables.  I use some postgres types such as TEXT and
BOOLEAN, which I would expect to map to LONGVARCHAR and BIT
respectively, but in the SQL that torque spit out they were "bytea" and
"".  I can't find mention of "bytea" in postgres docs, and obviously ""
isn't going to do much for me. =)

After reading the Torque docs, I really like what it offers but I'm not
sure that it will work for me.  Are there any other solutions that
people can recommend?  Or should I try modifying torque to fit my needs?
I don't have any EJB experience but I've heard good things about JBoss.
I've also heard the going EJB can really slow an application down. I've
also noticed some talk of Expresso on this list, would this be worth
trying?

Thanks for any advice!

-james

--
[]  James A. Hillyerd <[EMAIL PROTECTED]> - Java Developer
[]  PGP 1024D/D31BC40D F87B 7906 C0DA 32E8 B8F6 DE23 FBF6 4712 D31B C40D


--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to