equal
deleted
inserted
replaced
30 import java.util.ArrayList; |
30 import java.util.ArrayList; |
31 import java.util.List; |
31 import java.util.List; |
32 import java.util.concurrent.CompletableFuture; |
32 import java.util.concurrent.CompletableFuture; |
33 import java.util.concurrent.CompletionStage; |
33 import java.util.concurrent.CompletionStage; |
34 import java.util.concurrent.Flow; |
34 import java.util.concurrent.Flow; |
|
35 import java.util.concurrent.ForkJoinPool; |
35 import java.util.concurrent.Semaphore; |
36 import java.util.concurrent.Semaphore; |
36 import java.util.stream.Collector; |
37 import java.util.stream.Collector; |
37 import java.util.stream.Collectors; |
38 import java.util.stream.Collectors; |
38 |
39 |
39 /** |
40 /** |
171 } |
172 } |
172 group.releaseProhibitingMoreMembers(); |
173 group.releaseProhibitingMoreMembers(); |
173 } |
174 } |
174 } |
175 } |
175 |
176 |
176 // TransactionEnd |
177 // TransactionCompletion |
177 |
178 |
178 public void transaction(DataSource ds) { |
179 public void transaction(DataSource ds) { |
179 try (Session session = ds.getSession(t -> System.out.println("ERROR: " + t.toString()))) { |
180 try (Session session = ds.getSession(t -> System.out.println("ERROR: " + t.toString()))) { |
180 TransactionEnd trans = session.transactionEnd(); |
181 TransactionCompletion trans = session.transactionCompletion(); |
181 CompletionStage<Integer> idPromise = session.<Integer>rowOperation("select empno, ename from emp where ename = :1 for update") |
182 CompletionStage<Integer> idPromise = session.<Integer>rowOperation("select empno, ename from emp where ename = :1 for update") |
182 .set("1", "CLARK", AdbaType.VARCHAR) |
183 .set("1", "CLARK", AdbaType.VARCHAR) |
183 .collect(Collectors.collectingAndThen( |
184 .collect(Collectors.collectingAndThen( |
184 Collectors.mapping(r -> r.at("empno").get(Integer.class), |
185 Collectors.mapping(r -> r.at("empno").get(Integer.class), |
185 Collectors.toList()), |
186 Collectors.toList()), |
334 // MultiOperation |
335 // MultiOperation |
335 |
336 |
336 // LocalOperation |
337 // LocalOperation |
337 |
338 |
338 // SessionProperty |
339 // SessionProperty |
|
340 public enum ExampleSessionProperty implements SessionProperty { |
|
341 LANGUAGE; |
|
342 |
|
343 private static final String DEFAULT_VALUE = "AMERICAN_AMERICA"; |
|
344 |
|
345 @Override |
|
346 public Class<?> range() { |
|
347 return String.class; |
|
348 } |
|
349 |
|
350 @Override |
|
351 public Object defaultValue() { |
|
352 return DEFAULT_VALUE; |
|
353 } |
|
354 |
|
355 @Override |
|
356 public boolean isSensitive() { |
|
357 return false; |
|
358 } |
|
359 |
|
360 @Override |
|
361 public boolean configureOperation(OperationGroup<?, ?> group, Object value) { |
|
362 group.operation("ALTER SESSION SET NLS_LANG = " |
|
363 + group.enquoteIdentifier((String)value, false)) |
|
364 .submit(); |
|
365 return true; |
|
366 } |
|
367 |
|
368 } |
|
369 |
|
370 public Session getSession(DataSource ds) { |
|
371 return ds.builder() |
|
372 .property(ExampleSessionProperty.LANGUAGE, "FRENCH_FRANCE") |
|
373 .build() |
|
374 .attach(); |
|
375 } |
339 |
376 |
340 // Sharding |
377 // Sharding |
341 |
378 |
342 // TransactionOutcome |
379 // TransactionOutcome |
343 |
380 |