src/jdk.incubator.adba/share/classes/jdk/incubator/sql2/package-info.java
author lancea
Mon, 09 Jul 2018 15:09:06 -0400
branchJDK-8188051-branch
changeset 56824 62e92191354d
parent 56797 fb523d4d9185
child 56828 64304e37e9b1
permissions -rw-r--r--
JDK-8188051-branch latest updates
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
56380
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
     1
/*
56475
e700edfac7ad JDK-8188051-branch: Updates to sync with AOJ
lancea
parents: 56380
diff changeset
     2
 * Copyright (c)  2017, 2018, Oracle and/or its affiliates. All rights reserved.
56380
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
     4
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    10
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    15
 * accompanied this code).
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    16
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    20
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    23
 * questions.
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    24
 */
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    25
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    26
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    27
/**
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    28
 * <p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    29
 * An API for accessing and processing data stored in a data source (usually a
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    30
 * relational database) using the Java&trade; programming language. This API
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    31
 * includes a framework whereby different drivers can be installed dynamically
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    32
 * to access different data sources. This API is specifically geared for passing
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    33
 * SQL statements to a database though it may be used for reading and writing
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    34
 * data from/to any data source that has a tabular format.</p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    35
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    36
 * <p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    37
 * This API differs from the API in {@code java.sql} in several ways.</p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    38
 * <ul>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    39
 * <li>Is asynchronous
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    40
 * <li>Is geared toward high-throughput programs
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    41
 * <li>Does not attempt to support every database feature
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    42
 * <li>Does not attempt to abstract the database
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    43
 * <li>Uses the builder pattern
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    44
 * <li>Supports the fluent programming style
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    45
 * </ul>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    46
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    47
 * <p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    48
 * It is worth emphasizing that this API is an alternate to the {@code java.sql}
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    49
 * API, not a replacement. There are many programs that can much more readily be
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    50
 * written using the {@code java.sql} API as it has many features that are not
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    51
 * available in this API. For example this API provides almost no mechanism for
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    52
 * getting metadata.</p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    53
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    54
 * <p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    55
 * This API is not an extension to the {@code java.sql} API. It an independent
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    56
 * API and is used on its own without reference to java.sql. </p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    57
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    58
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    59
 * <h3>Overview</h3>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    60
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    61
 * <p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    62
 * The core feature of this API is that it is asynchronous. No method call will 
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    63
 * wait for a network operation. </p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    64
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    65
 * <p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    66
 * Possibly blocking actions are represented as {@link Operation}s. An
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    67
 * application using the API creates and submits one or more {@link Operation}s.
56475
e700edfac7ad JDK-8188051-branch: Updates to sync with AOJ
lancea
parents: 56380
diff changeset
    68
 * The implementation executes these {@link Operation}s asynchronously, reporting 
e700edfac7ad JDK-8188051-branch: Updates to sync with AOJ
lancea
parents: 56380
diff changeset
    69
 * their results via {@link java.util.concurrent.CompletionStage}s. An application
56380
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    70
 * can respond to the results via the
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    71
 * {@link java.util.concurrent.CompletionStage}s or via callbacks that can be
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    72
 * configured on many of the {@link Operation}s or both. Creating and submitting
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    73
 * {@link Operation}s is strictly non-blocking. Handling the results of possibly
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    74
 * blocking {@link Operation}s is done asynchronously. No application thread
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    75
 * will ever block on a call to a method in this API.</p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    76
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    77
 * <p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    78
 * All {@link Operation}s provide a
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    79
 * {@link java.util.concurrent.CompletionStage}. The value of that
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    80
 * {@link java.util.concurrent.CompletionStage} is the value of the
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    81
 * {@link Operation}, set when the {@link Operation} completes. Some
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    82
 * {@link Operation}s provide callbacks for processing the result of the
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    83
 * {@link Operation} independent of the
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    84
 * {@link java.util.concurrent.CompletionStage}. Those {@link Operation}s can
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    85
 * be used for executing SQL that returns results of a specific type. For
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    86
 * example SQL that returns a row sequence would be executed with a
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    87
 * {@link RowOperation}. A {@link RowOperation} provides callbacks for
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    88
 * processing each row and for collecting the results of processing the rows.
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    89
 * Other {@link Operation}s are specialized for SQL that returns a count or that
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    90
 * returns out parameters. The choice of {@link Operation} is dependent on the
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    91
 * result to be processed and is independent of the particular kind of SQL
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    92
 * statement.</p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    93
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    94
 * <p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    95
 * An {@link OperationGroup} encapsulates a group of {@link Operation}s and
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    96
 * executes them using common attributes. An {@link OperationGroup} can be
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    97
 * unconditional or conditional, sequential or parallel, dependent or
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    98
 * independent, or any combination of these. Dependent/independent controls
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
    99
 * error handling. If one member of a dependent {@link OperationGroup} fails the
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   100
 * remaining not-yet-executed members are completed exceptionally. If the
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   101
 * {@link OperationGroup} is independent, the member {@link Operation}s are
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   102
 * executed regardless of whether one or more fails.</p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   103
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   104
 * <p>
56824
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   105
 * A single context in a data source is represented by a {@link Session}. A 
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   106
 * {@link Session} is somewhat analogous to a logical {@link java.sql.Connection}.
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   107
 * A physical {@link java.sql.Connection} has no representation in this API; if
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   108
 * such an entity exists at all it is strictly internal to an implementation.
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   109
 * Within this spec this entity is referred to as a "data source resource".
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   110
 * </p>
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   111
 * 
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   112
 * <p>
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   113
 * A {@link Session} is itself an {@link OperationGroup} and so can be
56380
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   114
 * conditional, parallel, or independent, but by default is unconditional,
56824
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   115
 * sequential, dependent. While a {@link Session} may be created with values
56380
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   116
 * other than the defaults, using the defaults is by far the most common case.
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   117
 * The API provides convenience methods that support this case. Using these
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   118
 * convenience methods is recommended in all but the most unusual circumstances.
56824
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   119
 * In particular making the {@link Session} parallel introduces some
56380
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   120
 * challenges that would require a full understanding of the details of the API.
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   121
 * It would almost certainly be better to create a parallel
56824
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   122
 * {@link OperationGroup} within the {@link Session}.</p>
56380
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   123
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   124
 * <p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   125
 * <i>
56824
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   126
 * ISSUE: Should we disallow {@code Session.parallel()}?</i></p>
56380
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   127
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   128
 * <p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   129
 * The {@code java.sql} API frequently provides many ways to do the same thing.
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   130
 * This API makes no attempt to do this. For those capabilities this API
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   131
 * supports, it frequently defines exactly one way to do something. Doing things
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   132
 * another way, for example calling methods in a non-standard order, frequently
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   133
 * results in an IllegalStateException. This approach is intended to make things
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   134
 * simpler for both the user and the implementor. Rather than having to
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   135
 * understand complicated interactions of many different components and methods
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   136
 * executed in any order, the intent is that there is only one way to do things
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   137
 * so only one path must be understood or implemented. Anything off that path is
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   138
 * an error. While this requires a programmer to write code in one specific way
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   139
 * it makes things easier on future maintainers of the code as the code will
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   140
 * conform to the standard pattern. Similarly the implementation is simplified
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   141
 * as only the standard use pattern is supported.</p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   142
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   143
 * <p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   144
 * One way this API simplifies things in to define types as single use. Many
56475
e700edfac7ad JDK-8188051-branch: Updates to sync with AOJ
lancea
parents: 56380
diff changeset
   145
 * types are created, configured, used once, and are then no longer usable. Most
56380
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   146
 * configuration methods can be called only once on a given instance. Once an
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   147
 * instance is configured it cannot be reconfigured. Once an instance is used it
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   148
 * cannot be reused. This simplifies things by eliminating the need to
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   149
 * understand and implement arbitrary sequences of method calls that reconfigure
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   150
 * and reuse instances. Since objects are single use there is no expectation
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   151
 * that an application cache or share {@link Operation}s.</p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   152
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   153
 * <p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   154
 * While the user visible types are single use, it is expected that an
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   155
 * implementation will cache and reuse data and {@link Object}s that are worth
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   156
 * the effort. Rather than attempt to guess what an implementation should reuse
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   157
 * and capture that in the API, this API leaves it entirely up to the
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   158
 * implementation. Since the API specifies very little reuse, an implementation
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   159
 * is free to reuse whatever is appropriate. Since the pattern of use is
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   160
 * strictly enforced figuring out how to reuse objects is greatly
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   161
 * simplified.</p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   162
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   163
 * <p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   164
 * The {@code java.sql} API provides many tools for abstracting the database,
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   165
 * for enabling the user to write database independent code. This API does not.
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   166
 * It is not a goal of this API to enable users to write database independent
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   167
 * code. That is not to say it is not possible, just that this API does not
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   168
 * provide tools to support such. Abstraction features typically impose
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   169
 * performance penalties on some implementations. As this API is geared for
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   170
 * high-throughput programs it avoids such abstractions rather than reduce
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   171
 * performance.</p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   172
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   173
 * <p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   174
 * One such abstraction feature is the JDBC escape sequences. Implementing these
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   175
 * features requires parsing the SQL so as to identify the escape sequences and
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   176
 * then generating a new String with the vendor specific SQL corresponding to
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   177
 * the escape sequence. This is an expensive operation. Further each SQL must be
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   178
 * parsed whether it contains an escape sequence or not imposing the cost on all
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   179
 * JDBC users, not just the ones who use escape sequences. The same is true of
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   180
 * JDBC parameter markers. The SQL accepted by this API is entirely vendor
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   181
 * specific, including parameter markers. There is no need for pre-processing
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   182
 * prior to SQL execution substantially reducing the amount of work the
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   183
 * implementation must do.</p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   184
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   185
 * <p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   186
 * Note: It would be a reasonable future project to develop a SQL builder API
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   187
 * that creates vendor specific SQL from some more abstract representation.</p>
56475
e700edfac7ad JDK-8188051-branch: Updates to sync with AOJ
lancea
parents: 56380
diff changeset
   188
 * 
e700edfac7ad JDK-8188051-branch: Updates to sync with AOJ
lancea
parents: 56380
diff changeset
   189
 * <p>
e700edfac7ad JDK-8188051-branch: Updates to sync with AOJ
lancea
parents: 56380
diff changeset
   190
 * This API is targeted at high-throughput apps. If a particular feature of this
e700edfac7ad JDK-8188051-branch: Updates to sync with AOJ
lancea
parents: 56380
diff changeset
   191
 * API would have a surprising performance impact for a particular implementation
e700edfac7ad JDK-8188051-branch: Updates to sync with AOJ
lancea
parents: 56380
diff changeset
   192
 * it is recommended that the implementation not implement that feature. It is
e700edfac7ad JDK-8188051-branch: Updates to sync with AOJ
lancea
parents: 56380
diff changeset
   193
 * better that a feature be unsupported as opposed to users investing substantial
e700edfac7ad JDK-8188051-branch: Updates to sync with AOJ
lancea
parents: 56380
diff changeset
   194
 * effort in an app using that feature only to discover in production that the
e700edfac7ad JDK-8188051-branch: Updates to sync with AOJ
lancea
parents: 56380
diff changeset
   195
 * performance is unacceptable. For example, if an implementation can only support
e700edfac7ad JDK-8188051-branch: Updates to sync with AOJ
lancea
parents: 56380
diff changeset
   196
 * {@link Operation#timeout} through active polling it would be better for that
56797
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   197
 * implementation to throw  {@link UnsupportedOperationException} if 
56824
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   198
 * {@link Operation#timeout} is called. To this end every type and method is 
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   199
 * optional except returning a {@link DataSourceFactory} in response to a call to 
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   200
 * {@link DataSourceFactory#newFactory} with the appropriate name.</p>
56380
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   201
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   202
 * <h3>Execution Model</h3>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   203
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   204
 * <p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   205
 * <i>This section describes the function of a conforming implementation. It is
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   206
 * not necessary for an implementation to be implemented as described only that
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   207
 * the behavior be the same.</i></p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   208
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   209
 * <p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   210
 * An {@link Operation} has an action and a
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   211
 * {@link java.util.concurrent.CompletionStage}. Some {@link Operation}s have
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   212
 * some form of result processor.</p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   213
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   214
 * <p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   215
 * An {@link Operation} is executed by causing the action to be performed,
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   216
 * processing the result of the action if there is a result processor, and
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   217
 * completing the {@link java.util.concurrent.CompletionStage} with the result
56824
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   218
 * of the result processor if there is one. If the action or the result processing
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   219
 * causes an unhandled error the {@link java.util.concurrent.CompletionStage} is
56797
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   220
 * completed exceptionally. The {@link java.util.concurrent.CompletionStage} is
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   221
 * completed asynchronously, as though it were created by calling an
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   222
 * <i>async</i> method on {@link java.util.concurrent.CompletionStage}.
56380
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   223
 * </p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   224
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   225
 * <p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   226
 * Performing the action may require one or more interactions with the database.
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   227
 * These interactions may be carried out in parallel with processing the result.
56824
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   228
 * If the database result is ordered, that result is processed in the order
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   229
 * specified by the database.</p>
56380
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   230
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   231
 * <p>
56824
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   232
 * An {@link OperationGroup} has a collection of member {@link Operation}s and
56380
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   233
 * optionally a condition. For a sequential {@link OperationGroup}
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   234
 * {@link Operation}s are selected from the collection in the order they were
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   235
 * submitted. For a parallel {@link OperationGroup} {@link Operation}s are
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   236
 * selected from the collection in any order.</p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   237
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   238
 * <p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   239
 * The action of an {@link OperationGroup} is performed as follows:
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   240
 * <ul>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   241
 * <li>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   242
 * If the {@link OperationGroup} has a condition, the value of the condition is
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   243
 * retrieved. If the value is {@link Boolean#FALSE} the action is complete and
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   244
 * the {@link java.util.concurrent.CompletionStage} is completed with null. If
56797
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   245
 * the condition value completes exceptionally the action is complete and the
56380
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   246
 * {@link java.util.concurrent.CompletionStage} is completed exceptionally
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   247
 * with the same exception. If the condition value is {@link Boolean#TRUE} or
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   248
 * there is no condition the {@link Operation}s in the collection are executed
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   249
 * and their results processed. The action is complete when the
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   250
 * {@link OperationGroup} is not held and all the {@link Operation}s have been
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   251
 * executed.</li>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   252
 * <li>
56797
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   253
 * If the {@link OperationGroup} is parallel more than one member
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   254
 * {@link Operation} may be executed at a time.</li>
56380
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   255
 * <li>
56797
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   256
 * If the {@link OperationGroup} is dependent and a member {@link Operation} completes
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   257
 * exceptionally all member {@link Operation}s that are yet to begin
56380
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   258
 * execution are completed exceptionally with a {@link SqlSkippedException}. The
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   259
 * cause of that exception is the {@link Throwable} that caused the
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   260
 * {@link Operation} to be completed exceptionally. If an {@link Operation} is
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   261
 * in flight when another {@link Operation} completes exceptionally the in
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   262
 * flight {@link Operation} may either be allowed to complete uninterrupted or
56797
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   263
 * it may be completed exceptionally. The {@link OperationGroup} is dependent it
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   264
 * is completed exceptionally with the {@link Throwable} that caused the 
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   265
 * {@link Operation} to complete exceptionally. 
56475
e700edfac7ad JDK-8188051-branch: Updates to sync with AOJ
lancea
parents: 56380
diff changeset
   266
 * 
e700edfac7ad JDK-8188051-branch: Updates to sync with AOJ
lancea
parents: 56380
diff changeset
   267
 * <p>
56824
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   268
 * Note: the {@link Operation}s returned by {@link Session#closeOperation}
56479
045b7db933bd JDK-8188051-branch javadoc typo updates
lancea
parents: 56475
diff changeset
   269
 * and {@link OperationGroup#catchOperation} are never skipped, i.e. never 
56475
e700edfac7ad JDK-8188051-branch: Updates to sync with AOJ
lancea
parents: 56380
diff changeset
   270
 * completed exceptionally with {@link SqlSkippedException}. The {@link Operation}
e700edfac7ad JDK-8188051-branch: Updates to sync with AOJ
lancea
parents: 56380
diff changeset
   271
 * returned by {@link OperationGroup#catchOperation} never completes 
56797
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   272
 * exceptionally so the following {@link Operation} is always executed normally. 
56475
e700edfac7ad JDK-8188051-branch: Updates to sync with AOJ
lancea
parents: 56380
diff changeset
   273
 * No {@link Operation} can be submitted after the {@link Operation} returned by 
56824
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   274
 * {@link Session#closeOperation} has been submitted.</p> </li>
56380
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   275
 * <li>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   276
 * If the {@link OperationGroup} is independent and an {@link Operation}
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   277
 * completes exceptionally all other {@link Operation}s are executed regardless.
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   278
 * There is no result to be processed for an {@link Operation} that completed
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   279
 * exceptionally. The {@link OperationGroup} is not completed exceptionally as
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   280
 * the result of one or more {@link Operation}s completing exceptionally.</li>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   281
 * </ul>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   282
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   283
 * <p>
56824
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   284
 * A {@link Session} is a distinguished {@link OperationGroup}. A
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   285
 * {@link Session} is executed upon being submitted.</p>
56380
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   286
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   287
 * <h3>Transactions</h3>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   288
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   289
 * <p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   290
 * <i>This section describes the function of a conforming implementation. It is
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   291
 * not necessary for an implementation to be implemented as described only that
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   292
 * the behavior be the same.</i></p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   293
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   294
 * <p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   295
 * An implementation has only limited control over transactions. SQL statements
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   296
 * can start, commit, and rollback transactions without the implementation
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   297
 * having any influence or even being aware. This specification only describes
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   298
 * the behavior of those transaction actions that are visible to and controlled
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   299
 * by the implementation, i.e. the endTransaction {@link Operation}.
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   300
 * Transaction actions caused by SQL may interact with actions controlled by the
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   301
 * implementation in unexpected ways.</p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   302
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   303
 * <p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   304
 * The creation of Operations and the subsequent execution of those Operations
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   305
 * are separated in time. It is quite reasonable to determine that a transaction
56824
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   306
 * should commit after the Operation that ends the transaction is submitted. But
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   307
 * if the execution of the transaction does not result in the expected results
56380
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   308
 * it might be necessary to rollback the transaction rather than commit it. This
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   309
 * determination depends on the execution of the Operations long after the
56824
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   310
 * endTransaction Operation is submitted. To address this mismatch, the
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   311
 * endTransaction Operation is conditioned by a {@link TransactionEnd}. By
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   312
 * default, a {@link TransactionEnd} will cause an endTransaciton
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   313
 * {@link Operation} to commit the transaction. At any time before the
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   314
 * endTransaction {@link Operation} that references it is executed a
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   315
 * {@link TransactionEnd} can be set to rollback the transaction .</p>
56380
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   316
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   317
 * <p>
56824
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   318
 * An endTransaction {@link Operation}, like all {@link Operation}s, is
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   319
 * immutable once submitted. But an endTransaction {@link Operation} is created
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   320
 * with a {@link TransactionEnd} and that {@link TransactionEnd} can be set to
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   321
 * commit or rollback. A {@link TransactionEnd} controls the endTransaction
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   322
 * {@link Operation} created with it. Using this mechanism an error handler,
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   323
 * result handler or other code can cause a subsequent endTransaction
56475
e700edfac7ad JDK-8188051-branch: Updates to sync with AOJ
lancea
parents: 56380
diff changeset
   324
 * {@link Operation} to rollback instead of the default which is to commit.</p>
56380
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   325
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   326
 * <pre>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   327
 * {@code
56824
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   328
 *   TransactionEnd t = session.getTransactionEnd();
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   329
 *   session.countOperation(updateSql)
56380
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   330
 *       .resultProcessor( count -> { 
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   331
 *           if (count > 1) t.setRollbackOnly(); 
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   332
 *           return null; 
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   333
 *       } )
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   334
 *       .submit();
56824
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   335
 *   session.catchErrors();
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   336
 *   session.commitMaybeRollback(t);
56380
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   337
 * }
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   338
 * </pre>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   339
 *
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   340
 * <p>
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   341
 * In this example if the update SQL modifies more than one row the result
56824
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   342
 * processor will set the {@link TransactionEnd} to rollback only. When the
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   343
 * endTransaction {@link Operation} submitted by
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   344
 * {@link OperationGroup#commitMaybeRollback} is executed it will cause the
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   345
 * transaction to rollback.</p>
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   346
 *
56380
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   347
 *
56797
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   348
 * <h3>Implementation Note</h3>
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   349
 * 
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   350
 * <p>
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   351
 * If an implementation exposes any implementation specific types and methods, the
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   352
 * implementation is expected to provide covariant overrides for all methods that
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   353
 * return the standard super-type of the implementation specific type.</p>
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   354
 * 
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   355
 * <p>
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   356
 * Consider an implementation that adds a method foo() to RowCountOperation. To do
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   357
 * that it would have to expose a type FooRowCountOperation extends RowCountOperation.
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   358
 * So that an application can transparently access foo, the implementation would
56824
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   359
 * also have to expose FooDataSource, FooOperationGroup and FooSession. Further
56797
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   360
 * each of these types would have to declare covariant overrides for every method
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   361
 * that returns a direct super-type of one of these types.</p>
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   362
 * <ul>
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   363
 * <li>FooDataSourceFactory must override builder to return FooDataSource.Builder</li>
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   364
 * <li>FooDataSource.Builder must override url, password, etc to return a
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   365
 * FooDataSource.Builder. build must return a FooDataSource.</li>
56824
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   366
 * <li>FooDataSource must override builder to return FooSession.Builder</li>
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   367
 * <li>FooSession.Builder must override url, password, etc to return a 
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   368
 * FooSession.Builder. build must return a FooSession</li>
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   369
 * <li>FooDataSource must override getSession to return FooSession</li>
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   370
 * <li>FooSession must extend FooOperationGroup</li>
56797
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   371
 * <li>FooOperationGroup> must override rowCountOperation to return FooRowCountOperation</li>
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   372
 * <li>FooRowCountOperation must override apply and onError to return FooRowCountOperation</li>
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   373
 * </ul>
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   374
 * <p>
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   375
 * The intent is to transparently expose the vendor extension without use of casts.
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   376
 * Example: </p>
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   377
 * 
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   378
 * <pre>
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   379
 * {@code
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   380
 *   FooDataSourceFactory factory = DataSourceFatory.newFactory("com.foo.FooDataSourceFatory");
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   381
 *   FooDataSource dataSource = factory.builder()
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   382
 *       .url("scott/tiger@host:port")
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   383
 *       .build();
56824
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   384
 *   FooSession session = dataSource.getSession();
62e92191354d JDK-8188051-branch latest updates
lancea
parents: 56797
diff changeset
   385
 *   CompletionStage<Long> count = session.rowOperation(sql)
56797
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   386
 *       .set("param", value, AdbaType.VARCHAR)
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   387
 *       .foo()
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   388
 *       .submit()
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   389
 *       .getCompletionStage();
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   390
 * }
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   391
 * </pre>
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   392
 * 
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   393
 * <p>
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   394
 * Notice that there are no casts, yet both standard methods an the vendor extension
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   395
 * method foo can be referenced. This is possible only if the implementation exposes
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   396
 * all the necessary types and provides covariant overrides for every method that
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   397
 * returns one of those types. Implementations are expected (required?) to do this.
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   398
 * </p>
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   399
 * 
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   400
 * <p>
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   401
 * If an implementation does not expose any implementation specific methods or 
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   402
 * types, that implementation is not required to provide covariant overrides that
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   403
 * return implementation specific types.</p>
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   404
 * 
fb523d4d9185 JDK-8188051-branch updates
lancea
parents: 56479
diff changeset
   405
 * 
56380
f06946e00a26 JDK-8188051-branch: add jdk.incubator.adba
lancea
parents:
diff changeset
   406
 */
56475
e700edfac7ad JDK-8188051-branch: Updates to sync with AOJ
lancea
parents: 56380
diff changeset
   407
 package jdk.incubator.sql2;
56479
045b7db933bd JDK-8188051-branch javadoc typo updates
lancea
parents: 56475
diff changeset
   408