Creating Operation without Connection

Douglas Surber douglas.surber at oracle.com
Fri Oct 6 14:58:42 UTC 2017


Operation is an interface. Concrete classes that implement that interface are vendor specific. It would be feasible to define an OperationFactory interface that each vendor would implement. Then user code could get an Operation from the factory and submit it to a Connection. This introduces the possible error of submitting an Operation from one vendor to a Connection from another. Making the Connection (really OperationGroup) the factory eliminates the possibility of submitting an Operation to the wrong Connection.

This is a general design principle for the API, avoiding as much as possible passing one vendor specific object to another vendor specific object buy creating the passed object in the right place to begin with. It’s not always possible but we try.

You are correct however that creating an Operation does not do a round trip to the database. That’s not to say it isn’t database specific.

Douglas

> On Oct 6, 2017, at 7:44 AM, Dimitar Georgiev <dimitar.georgiev.bg at gmail.com> wrote:
> 
> Didn't spend a lot of time in the code yet, sorry if this is a dumb question.
> 
> Since Operation is merely a description of something to be executed
> against the database, shouldn't the act of creating one be
> referentially transparent? E.g. I should be able to write `public
> static Operation<List<Thing>> selectTheThings(){}` and that method
> will have no side effects itself. Right now creating creating an Op
> seems to be tied to having an instance of Connection, IIUC?
> 
> Regards, Dimitar



More information about the jdbc-spec-discuss mailing list