Re: Generating SQL
From: Mark Nicholls (Nicholls.Mark_at_mtvne.com)
Date: 11/08/04
- Next message: Mark Nicholls: "Re: Opinions on the Law Of Demeter"
- Previous message: ShadowMan: "Re: EJB container managed transaction"
- In reply to: Otavio C. Decio: "Re: Generating SQL"
- Next in thread: Otavio C. Decio: "Re: Generating SQL"
- Reply: Otavio C. Decio: "Re: Generating SQL"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 8 Nov 2004 01:46:41 -0800
"Otavio C. Decio" <REMOVEodecio@earthlink.REMOVE.net> wrote in message news:<r7KdnWnCSqFhtxPcRVn-qg@giganews.com>...
> Sorry for the bad formatting. Hope this will show up better:
>
>
>
> ArrayList songArray;
>
> /* Entity class, basically a bunch of property
> sets/gets */
>
> Song song;
>
> /* Helper class to define search criteria = WHERE clause */
> SearchCriteria sc = new SearchCriteria();
>
> /* Overloaded function to define bindings of various types */
> sc.AddBinding(SearchBoolean.AND, "Singer",SearchOperator.EQUAL,"Rammstein");
>
>
> /* DAO will use the type of the Song object, reflect it and generate the SQL
> */
> songArray = DAO.Load(sc, typeof(Song));
>
> /*//Notice that I have strong typing here */
> ((Song)soft[0]).mp3Comments = "Big band";
>
> /*Same concept here, reflection and attributes will create the appropriate
> SQL and return # of records affected. */
> iCount = DAO.Update((Song)soft[0]);
>
>
> "Otavio C. Decio" <REMOVEodecio@earthlink.REMOVE.net> wrote in message
> news:3bSdnfNXfd-XtxPcRVn-iw@giganews.com...
> > Mark,
> >
> > Here's an example of something I wrote (C#):
> >
> > ArrayList songArray;
> > Song song; //Entity class, basically a bunch of property
> > sets/gets
> > SearchCriteria sc = new SearchCriteria(); //Helper class to define
> > search criteria = WHERE clause
> > sc.AddBinding(SearchBoolean.AND,
> "Singer",SearchOperator.EQUAL,"Rammstein");
> > //Overloaded function to define bindings of various types
> > songArray = DAO.Load(sc, typeof(Song)); // DAO will use the type of the
> > Song object, reflect it and generate the SQL
> > ((Song)soft[0]).mp3Comments = "Big band"; //Notice that I have strong
> > typing here
> > iCount = DAO.Update((Song)soft[0]); //Same concept here, reflection and
> > attributes will create the appropriate SQL and return # of records
> affected.
> >
> > Seriously, do you think somethink like this would be helpful? I developed
> an
> > entire application using this, and it is in production right now. But as I
> > wrote it by myself I have very little feedback on its usability.
> >
> > Otavio
> >
> >
I've done similar things, but I've only really got as far as single
query/filter. I like it because I can autogenerate the SQL when the
data dictionary changes, change visibility of field to different
'views', etc etc, there was always a problem though when the SQL got a
bit fiddly...i.e. inner queries, self joins, not impossible but it all
gets a little messy.
I think there is value here. Apart from the above and the obvious
isolation of the SQL dialect (or other) from the code, I think it
makes sense to express the logic in the same language as the code
itself and simply map that to SQL when required.
I suspect you did it for a reason...did you think it was a good idea?
- Next message: Mark Nicholls: "Re: Opinions on the Law Of Demeter"
- Previous message: ShadowMan: "Re: EJB container managed transaction"
- In reply to: Otavio C. Decio: "Re: Generating SQL"
- Next in thread: Otavio C. Decio: "Re: Generating SQL"
- Reply: Otavio C. Decio: "Re: Generating SQL"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|