cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Willerding <>
Subject Re: Standalone app, Threads and Object contexts
Date Wed, 02 May 2012 18:54:44 GMT
On 05/02/2012 10:35 AM, Michael Gentry wrote:
> Creating a new DataContext may or may not be the right approach for 
> your application, but to say it "is not a recommended practice" would 
> be incorrect. If your requests are naturally isolated from other 
> requests, there is no harm in creating a new DataContext/request. 
I got that quote from the Cayenne Guide

so that was got me thinking about the whole thread topic and what might 
be the recommended practice for a multi-threaded stand-alone app.

> DataContexts (parent/child/whatever) are not tied at all to the 
> connection pool limits. Creating a DataContext is cheap, too. Create 
> all that you need. 

I am beginning to understand this now but in my "extreme" case of 200 
simultaneous requests to a DataContext can I simply create 200 new 
DataContexts using code like

            String fileName = "etc/cayenne.xml";
            org.apache.cayenne.conf.FileConfiguration conf = new org.apache.cayenne.conf.FileConfiguration(fileName);
	   DataContext dc = DataContext.createDataContext();

without causing multiple open/close connections to the underlying database?

And where does the underlying connection pool set for lets say 20 
maximum connections come in to play?  In the code example above, will a 
createDataContext() fail at the 21st request?
>> 4)  Or am I way off base and making things more complicated than they should
>> be? ;-)
> Probably.  :-)
My thanks to the forum monitors for your patience and explanations!!
> PS. You keep mentioning child contexts.  Do you *need* child contexts?

View raw message