Search the web
Sign In
New User? Sign Up
SimpleORM
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want your group to be featured on the Yahoo! Groups website? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
The Big Split -- SimpleOrm.records and SimpleOrm.database.   Message List  
Reply | Forward Message #1559 of 1851 |
Re: [SimpleORM] The Big Split -- SimpleOrm.records and SimpleOrm.database.

Anthony,

I was wondering, why must have so many static methods in SSession, that
most of the time end up finding the current scon in threadlocal, instead
of returning a SSession instance on open(), and passing around the
pointer as needed ?

(I must admit I am not that comfortable with multi-threading issues, so
what I am saying might be stupid)

Wouldn't:

SSession ses = SSession.open(datasource);

ses.begin();
ses.attachDataSet(ds);
List<Record> res = ses.findOrcreate(...);
ses.flush();
SDataSet newDs = ses.detachDataSet();
ses.commit();

SSession.closeSession();

be better ? So the factory+threadLocal part of SSession would be clearly
identified (public static methods open() and closeSession()), every
other public method beeing instance methods. This would avoid having to
get the current session from threadLocal every now and then in the code,
and would make clear SSession really has two distinct purposes.

As I already said, I am not sure at all about what I'm stating, so your
opinion on this really matters :)

Franck



Le jeudi 03 juillet 2008 à 09:50 +0200, Franck Routier a écrit :
> Hi,
>
> ok, I really
> like
SSession.newSessionAndAssociateWithCurrentThreadAndOpenJdbcConnection(),
which really says what it does..... :)
>
> I agree with the fact that a dataset must be a whole transaction
> cache,
> and that a session can only operate on one dataset at a time
> (begin/commit). And a record is either detached (from any dataset) or
> bound to one datset only. This makes sense to me, and doing otherwise
> is
> too far from what we've done until now. Would be scary :)
>
> The point I have trouble with is attach / detach semantics. What do
> you
> think it should be ?
>
> - only detach datset / or detach one record ?
> - only attach dataset / attach one record ?
> - if you are in an ongoing transaction, attaching a dataset mean
> merging
> the dataset, no only moving pointer... (I think of the updateList in
> particular)
>
> What do you think ?
>
> Franck
>
> Le jeudi 03 juillet 2008 à 15:10 +1000, Anthony Berglas a écrit :
> > Hello Franck,
> >
> > You've been busy again.
> >
> > >I agree with everything you say here. Regarding naming, maybe we
> > should
> > >consider JPA terminology ? Then Session would be EntityManager.
> > >And session.open() would then be joinTransaction()...
> >
> > I'm not sure that joinTranction a good description for
> > SSession.open. Maybe
> >
> SSession.newSessionAndAssociateWithCurrentThreadAndOpenJdbcConnection
> > would be explicit. But that is a bit too long. I personally like
> > just .open.
> >
> > I see what you have been trying to do with SDataSet etc. Might I
> > suggest:-
> >
> > SDataSet moves to simpleorm.record. It has no SSession variable. It
> > does have transactionCache (maybe renamed to just records) and
> > updateList. It contains implementations of findOrCreate etc. that
> > query its transactionCache (which just returns pointers to records
> in
> > its transactionCache). I do not think that it needs to implement
> any
> > interfaces.
> >
> > SRecordFinder is renamed database.SDataSetJdbc and extends
> > SDataSet. It is a data set that has been extended by a database. It
> > implements findOrCreate etc. to query the database. It is not a
> > public class for now, only dispached to via SSession.
> >
> > SSession creates one new SDataSetJdbc instance in BeginTransaction,
> > which it nulls at commit/rollback. SSession.findOrCreate just
> > dispatches to SDataSetJdbc.
> > (Avoid creating garbage per simple query. There can be quite a lot
> > of them, and performance is not completely unimportant.)
> > SSession contains the ThreadLocal code. SSession and SDataSetJdbcr
> > are really just one class split into two for convenience.
> >
> > SQueryEngine and SManager are deleted. (Interfaces can always be
> > easily added back later if useful, otherwise they are clutter.)
> >
> > SDataSet.query(SQuery) can just throw a unimplemented exception for
> > now. But its @Override in SDataSetJdbc does the normal execute.
> >
> > Attaching an SDataSet to a SSession/SDataSetJdbc just moves
> pointers
> > to records over. An SRecordInstance can only ever belong to one
> > SDataSet at a time (many problems otherwise). So attach method
> > should be called something like
> > SSession/SDataSetJdbc.moveRecordsFrom(SDataSet ds), and should
> remove
> > them from ds.
> >
> > What do you think?
> >
> > (One alternative view is that an SDataSet should just be a
> > List<SRecordInstance>. And queries would return an SDataSet rather
> > than a List. But SDataSets contain many different types of
> > records. And we would have records occurring in multiple data sets
> > at the same time, very dangerous.)
> >
> > Anthony
> >
> > At 08:52 PM 2/07/2008, Franck Routier wrote:
> >
> > >Hello Anthony,
> > >
> > >I agree with everything you say here. Regarding naming, maybe we
> > should
> > >consider JPA terminology ? Then Session would be EntityManager.
> > >
> > >And session.open() would then be joinTransaction()...
> > >
> > >The advantage of EntityManager over Session is that it explicitely
> > >states what it does. And SDataSet would also be an EntityManager...
> > >
> > >So maybe SSession and SDataSet would both implement
> "EntityManager".
> > But
> > >I don't think we should go for JPA EntityManager stricto sensu, the
> > API
> > >is quite poor and we wouldn't want to depends on it and guarantee
> the
> > >contract.
> > >
> > >Do you agree with that ?
> > >
> > >So what I propose is to have a common interface for SSession and
> > >SDataSet, lets call it SManager.
> > >
> > >I'll try this, and you can review it tomorow and tell if you like
> > it...
> > >
> > >Have a good night :)
> > >
> > >Franck
> > >
> > >BTW, where are you located (Austalia ?) I am in Clermont-Ferrand
> > >(France) and my local timezone is CEST (Continental Europe).
> > >
> >
> > Dr Anthony Berglas, anthony@... Mobile: +61 4 4838 8874
> > Just because it is possible to push twigs along the ground with ones
> > nose
> > does not necessarily mean that is the best way to collect firewood.
> >
> >
> >
> >
> >
>
>
>
>
>





Thu Jul 3, 2008 12:35 pm

routier_franck
Offline Offline
Send Email Send Email

Forward
Message #1559 of 1851 |
Expand Messages Author Sort by Date

Hello Franck, I think that as part of 3.0 we should consider splitting SimpleOrm into two pieces, each in their own Jars. simpleorm.records that contains...
Anthony Berglas
aberglas
Offline Send Email
Jun 30, 2008
5:57 am

Hello Frank, Moving SQuery out is possible. One would have to store the built query as a structure rather than a query string, and then translate to string in...
Anthony & Melissa Ber...
berglas@...
Send Email
Jun 30, 2008
10:45 am

Anthony, maybe we should consider introducing SDataSet (or SDataSetManager ?) right now. First it would be equivalent to SConnection's transaction cache and ...
Franck Routier
routier_franck
Offline Send Email
Jun 30, 2008
2:24 pm

Hello Franck, Hmm. The design gets ever more ambitious. I am concerned that if we take on too much we will not finish. But it would be good to get this...
Anthony Berglas
aberglas
Offline Send Email
Jul 1, 2008
11:18 am

Hi Anthony, that seems fine to me, except for one point that is not that clear :) shouldn't "myDS.create(new Employee().set(Employee.ID, "123").set.....);"...
Franck Routier
routier_franck
Offline Send Email
Jul 1, 2008
2:46 pm

Anthony, I've done some work, namely steps 1 to 6, execpt for the 'flush before query part'. Lot of thinks are now public, including some fields. Bad. Also...
Franck Routier
routier_franck
Offline Send Email
Jul 1, 2008
7:59 pm

Hello Franck, Wow, you have been busy. I agree that we need to be careful about our vocabulary, I had been a bit sloppy. SCon."attach/detach" had referred to ...
Anthony Berglas
aberglas
Offline Send Email
Jul 2, 2008
10:18 am

Hello Anthony, I agree with everything you say here. Regarding naming, maybe we should consider JPA terminology ? Then Session would be EntityManager. And...
Franck Routier
routier_franck
Offline Send Email
Jul 2, 2008
10:52 am

Hello Franck, You've been busy again. ... I'm not sure that joinTranction a good description for SSession.open. Maybe ...
Anthony Berglas
aberglas
Offline Send Email
Jul 3, 2008
5:11 am

Hi, ok, I really like SSession.newSessionAndAssociateWithCurrentThreadAndOpenJdbcConnection(), which really says what it does..... :) I agree with the fact...
Franck Routier
routier_franck
Offline Send Email
Jul 3, 2008
7:50 am

Anthony, I was wondering, why must have so many static methods in SSession, that most of the time end up finding the current scon in threadlocal, instead of...
Franck Routier
routier_franck
Offline Send Email
Jul 3, 2008
12:35 pm

Hmm. The motivations for attaching the session to a thread local were:- 1. It avoids having to pass a connection variable everywhere. In a database...
Anthony Berglas
aberglas
Offline Send Email
Jul 4, 2008
2:11 am

Hello Franck To keep it simple, the semantics of attaching a data set to a session could be exactly the same as attaching each record in it, one by one. As ...
Anthony Berglas
aberglas
Offline Send Email
Jul 4, 2008
12:47 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help