RE: Re: Record caching

gary adams <[email protected]> Mon, 8 Jun 2009 10:27:38 -0400
Newsgroups gmane.comp.java.orm.simpleorm
Message-ID <[email protected]>
Thanks for the response.
 
I looked thru LongTransactionTest.  From what I see, it looks like the code assumes it can set the dataset for a session.   I dont know the order in which my classes will be called.  And if they are doing lazy loading of data, I always run the risk that session.begin() has already been called by some other class in this thread and therefore the class will get an exception by calling ses.begin(ds).
 
GA
 





To: [email protected]
From: [email protected]
Date: Mon, 8 Jun 2009 10:11:33 +1000
Subject: Re: [SimpleORM] Re: Record caching








Hello Gary

You could also just reattach the data set to a session (ses.begin(ds)) updated it, then detachAndCommit again. See LongTransactionTest.simpleDetachTest.

But yes, only one data set at a time per session. Hard to see how that would be a problem, but bad things could happen otherwise. (You could trick SimpleORM into having two sessions for the same JDBC connection, but that would probably be a very bad idea.)

As noted previously on this list, the single record detaching from Sessions has been completely removed from the Subversion version. Now records must always live in a DataSet. The SDataSet.attach method that you were using is for internal use only.

Anthony

At 04:24 AM 8/06/2009, you wrote:

>--- In <mailto:SimpleORM%40yahoogroups.com>[email protected], gary adams <gershonadams@...> wrote:
>>
>> 
>> I have been using SimpleORM for the last two months and its a great tool. I have a question about record caching
>> 
>> 
>> 
>> If one has static information in the database that he wants to cache in an application, like configuration information, what is the proper methodology of doing this with simpleORM? The app will need access to this information throughout its life.
>> 
>> 
>> 
>> I have done it likes this.
>> 
>> 
>> LIST<x> listX= session.queryNoFlush(queryDEF);
>> session.commitAndDetachDataSet();
>> 
>> Is this correct? I am concerned that the commit being done in the class that requires the cache will affect other items in the database that should not be committed yet.
>> 
>
>You can make this action as first one after starting your program. So no other items in the database can be affected, because your program hasn't any open transactions yet. 
>
>> Along the same lines, what is the proper way to attaching records to a dataset from a rawquery? I have used
>> session.getDataSet().attach(record), but I am concerned because it is deprecated.
>
>You can use something like:
>
>SRecordMeta<? extends SRecordInstance> metaRec;
>SRecordInstance record = dataSet.createWithNullKey( metaRec );
>
>Then you fill the record with functions like:
>
>record.setString( f, value );
>
>Good luck
>Thomas
>
>

Spreadsheet Detective,
Southern Cross Software Queensland Pty Limited
54 Gerler Street
Bardon, Queensland 4065, Australia.

Email: [email protected]
www.SpreadsheetDetective.com
Ph: +61 427 830248 (Australian Eastern Standard Time)

"If the model seems correct only because the numbers look right, 
then why build the model in the first place?"








_________________________________________________________________
Lauren found her dream laptop. Find the PC that’s right for you.
http://www.microsoft.com/windows/choosepc/?ocid=ftp_val_wl_290