referencing columns
Douglas Surber
douglas.surber at oracle.com
Mon May 7 15:02:22 UTC 2018
Slice is useful when a subsequence of columns form a larger concept, especially when that subsequence is used multiple times, eg address. A query could return mailing address and shipping address.
mailingAddress = readAddress(col.at <http://col.at/>(“mailing_address”).slice(5));
shippingAddress = readAddress(col.at <http://col.at/>(“shipping_address).slice(5));
public Address readAddress(Column col) {
return new Address(col.get(String.class), // street 1
col.next().get(String.class), // street 2
col.next().get(String.class), // city
col.next().get(String.class), // state
col.next().get(String.class)); // postal code
Using slice isolates the caller from the motion done by the subroutine. It also allows the method to use forEach and other iterator methods.
Douglas
> On May 7, 2018, at 4:28 AM, Vladimir Sitnikov <sitnikov.vladimir at gmail.com> wrote:
>
> I agree, slice method looks odd.
>
More information about the jdbc-spec-discuss
mailing list