Without getting into too much detail, I will say that the model you  
describe below will generally work.  You can use EJBs (entity beans)  
for writing and reading data, then use some other mechanism for  
querying the database.  I have heard this referred to as the "fast  
track" model as it allows you the convenience of EJBs and the speed of  
going directly to the database.  In other words, when you use an entity  
bean to save a property (essentially to insert or update a row of  
data), you are typically touching two physical servers: your  
application server and your database server.  This is not always the  
case as your application server and your servlet engine may very well  
be on the same box, but one of the great things about EJBs is that they  
are potentially distributed, so let's assume your EJB container is  
running on a separate box from your servlet engine or CFMX server.   
Rather than using entity beans to generate a report, for example, you  
can go right from your servlet engine/CFMX server to your database,  
skipping your middle tier application server.  This type of access is  
far faster than using entity beans.

One thing to watch out for, however: going behind the application  
server's back is potentially dangerous.  By allowing your server to  
manage persistence for you, unless you are careful, you actually don't  
know at what point data is getting written to the database.  In other  
words, you may set a property on an entity and expect that data to go  
directly into the database, then query the database from your CFMX  
server only to find that the data is not there.  If you were to ask the  
entity bean, however, the expected data would be returned.  That's  
because since the application server is managing the data, it will  
decide when the most opportune time is to write that data to the  
database.  In fact, it may even passivate (serialize) entity beans  
before writing that bean's data to disk (though I'm not certain of  
this).  If you want to have the best of both worlds (direct access to  
the database and container managed persistence), you have to make sure  
that your entity beans are writing data to the database immediately (I  
think this is generally a vendor-specific configuration option).   
Naturally, performance is likely to suffer, however the advantage of  
being able to go directly to the database to run queries outweighs the  
disadvantages of real-time insert and updates, in my experience.  In  
applications I have built in the past, I have always done far more  
reading from the database than writing to it, so it made more sense to  
optimize the queries than the inserts and updates.

Christian

On Wednesday, January 15, 2003, at 07:55 PM, Samuel Neff wrote:

> I just finished reading the CRM section of Ben Forta's CFMX/J2EE book
> and am curious about using Entity Beans for database access.  The book
> described them as fairly involved to develop and deploy and provided
> relatively poor performance.  One of the issues discussed with the
> application, albeit fictional, was the slow response time of the Entity
> EJB's.
>
> My understanding is if you wanted to use an EJB for db access and take
> advantage of object pooling and distributed deployment you can use a
> stateless session bean with JDBC code to query the database and return
> Java objects.
>
> That said, you can still use CFQUERY and access J2EE level datasources
> attached to the app server's connection pools.
>
> Can those of you with experience in J2EE describe which of these you've
> used and the advantages/disadvantages and why you made that choice?
> Which would you recommend for a CFMX/J2EE application and what other
> factors should be taken into account?
>
> Thanks,
>
> Sam
>
>
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to