Skip to content

Commit 7866d5c

Browse files
author
Tomáš Kraus
committed
Last meeting notes applied.
Signed-off-by: Tomáš Kraus <[email protected]>
1 parent 83a052f commit 7866d5c

File tree

2 files changed

+40
-49
lines changed

2 files changed

+40
-49
lines changed

docs/src/main/asciidoc/includes/data.adoc

Lines changed: 27 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ represents the type of the entity's primary key attribute. Composite primary key
155155
156156
The `Data.GenericRepository` interface is extended by additional interfaces that add specific features:
157157
158-
[cols=2*]
158+
[cols="20%,80%"]
159159
|===
160160
|Interface |Description
161161
@@ -341,7 +341,7 @@ Method arguments are consumed in the same order as the condition keywords appear
341341
342342
Criteria modifiers:
343343
344-
[cols=2*]
344+
[cols="10%,90%"]
345345
|===
346346
|Keyword |Description
347347
@@ -429,16 +429,16 @@ Supported condition keywords:
429429
|The property value is `false`. Requires `boolean` or `Boolean` property.
430430
|===
431431
432-
An example method that returns all entities whose `age` attribute is greater than the provided value:
432+
An example repository method with criteria:
433433
434434
[source,java]
435435
----
436-
include::{sourcedir}/includes/data/PetRepositorySnippets.java[tag=qbmn_criteria_method, indent=0]
436+
include::{sourcedir}/includes/data/PetRepositorySnippets.java[tag=qbmn_criteria_methods, indent=0]
437437
----
438438
439439
Logical operators:
440440
441-
[cols=2*]
441+
[cols="10%,90%"]
442442
|===
443443
|Keyword |Description
444444
@@ -449,6 +449,13 @@ Logical operators:
449449
|Logical OR
450450
|===
451451
452+
An example repository method with criteria and logical operator:
453+
454+
[source,java]
455+
----
456+
include::{sourcedir}/includes/data/PetRepositorySnippets.java[tag=qbmn_multiple_criteria_methods, indent=0]
457+
----
458+
452459
NOTE: In JPQL, operator precedence places `AND` above `OR` as defined in Jakarta Persistence 3.1, section 4.6.6.
453460
The same rule applies to SQL.
454461
@@ -461,7 +468,7 @@ keywords, so only the last keyword is optional.
461468
462469
Ordering keywords:
463470
464-
[cols=2*]
471+
[cols="10%,90%"]
465472
|===
466473
|Keyword |Description
467474
@@ -519,7 +526,7 @@ The `PageRequest` argument defines the page size and the page index, starting fr
519526
520527
Returned page content types:
521528
522-
[cols=2*]
529+
[cols="10%,90%"]
523530
|===
524531
|Name |Description
525532
@@ -620,89 +627,62 @@ Helidon JTA Transaction support, such as Narayana, may be provided at runtime to
620627
621628
If JTA transaction support is not provided, Helidon Data runtime will use `RESOURCE_LOCAL` transaction type.
622629
623-
=== Transaction Types
630+
=== Transaction Types and Annotations
624631
625632
The `Tx` class defines several ways how transactional support can be applied to transactional method executions.
626633
Those ways are defined in `Tx.Type` enum.
634+
The `Tx` class also defines annotations that can be used to mark methods for transactional execution
635+
based on `Tx.Type` enum.
627636
628-
==== Transaction Type Enum
629-
The `Tx.Type` enum is used to describe the possible ways in which transactional support must be applied
630-
to transactional method executions.
631-
632-
===== Enum Values and Their Meanings
633-
634-
The Type enum has six values, each representing a different transactional behavior:
635-
636-
[cols=2*]
637+
[cols=3*]
637638
|===
638-
|Name |Description
639+
|Enum |Annotation |Description
639640
640641
|`MANDATORY`
642+
|`@Mandatory`
641643
|A transaction must already be in effect when a method executes. If called outside a transaction
642644
context, a `TxException` is thrown. If called inside a transaction context, method execution continues
643645
under that context.
644646
645647
|`NEW`
648+
|`@New`
646649
|A new transaction is started when a method executes. If called outside a transaction context, a new
647650
transaction is begun. If called inside a transaction context, the current transaction is suspended, a new
648651
transaction is begun, and the method execution continues inside this new transaction context.
649652
650653
|`NEVER`
654+
|`@Never`
651655
|No transaction must be in effect when a method executes. If called outside a transaction context, method
652656
execution continues outside a transaction context. If called inside a transaction context, a `TxException`
653657
is thrown.
654658
655659
|`REQUIRED`
660+
|`@Required`
656661
|A transaction will be in effect when a method executes. If called outside a transaction context,
657662
a new transaction is begun. If called inside a transaction context, method execution continues inside
658663
that transaction context.
659664
660665
|`SUPPORTED`
666+
|`@Supported`
661667
|A transaction may optionally be in effect when a method executes. If called outside a transaction
662668
context, method execution continues outside a transaction context. If called inside a transaction context,
663669
method execution continues inside that transaction context.
664670
665671
|`UNSUPPORTED`
672+
|`@Unsupported`
666673
|No transaction will be in effect when a method executes. If called outside a transaction context, method
667674
execution continues outside a transaction context. If called inside a transaction context, the current
668675
transaction is suspended, method execution continues outside a transaction context, and the previously
669676
suspended transaction is resumed after method execution completes.
670677
|===
671678
672-
=== Transaction Annotations
673-
674-
The `Tx` class defines several annotations that can be used to mark methods for transactional execution:
675-
676-
[cols=2*]
677-
|===
678-
|Annotation |Description
679-
680-
|`@Mandatory`
681-
|Indicates that a method will be executed with a managed transaction of type `MANDATORY`.
682-
683-
|`@New`
684-
|Indicates that a method will be executed with a managed transaction of type `NEW`.
685-
686-
|`@Never`
687-
|Indicates that a method will be executed with a managed transaction of type `NEVER`.
688-
689-
|`@Required`
690-
|Indicates that a method will be executed with a managed transaction of type `REQUIRED`.
691-
692-
|`@Supported`
693-
|Indicates that a method will be executed with a managed transaction of type `SUPPORTED`.
694-
695-
|`@Unsupported`
696-
|Indicates that a method will be executed with a managed transaction of type `UNSUPPORTED`.
697-
|===
698-
699679
=== Transaction Methods
700680
701681
The `Tx` class provides several methods for executing tasks within a transaction:
702682
703-
[cols=2*]
683+
[cols="20%,80%"]
704684
|===
705-
|Annotation |Description
685+
|Method |Description
706686
707687
|`transaction(Callable<T> task)`
708688
|Executes a task with a managed transaction of type `REQUIRED`.

docs/src/main/java/io/helidon/docs/includes/data/PetRepositorySnippets.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,20 @@ public interface PetRepositorySnippets extends Data.GenericRepository<Pet, Integ
3535
long longCountByName(String name);
3636
// end::qbmn_method[]
3737

38-
// tag::qbmn_criteria_method[]
38+
// tag::qbmn_criteria_methods[]
39+
// Returns Keeper entity with keepr.name matching provided name
40+
// or throws an exception when no such entity exists
41+
Keeper getByName(String name);
42+
// Returns list of Keeper entities with keepr.age > provided age value
3943
List<Keeper> listByAgeGreaterThan(int age);
40-
// end::qbmn_criteria_method[]
44+
// Checks whether at least one entity with keepr.age between provided
45+
// min and max values exists
46+
boolean existsByAgeBetween(int min, int max);
47+
// end::qbmn_criteria_methods[]
48+
49+
// tag::qbmn_multiple_criteria_methods[]
50+
Optional<Keeper> findByNameAndAge(String name, int age);
51+
// end::qbmn_multiple_criteria_methods[]
4152

4253
// tag::qbmn_sort_method[]
4354
List<Keeper> listAllOrderByAgeAscName();

0 commit comments

Comments
 (0)