File tree Expand file tree Collapse file tree 4 files changed +25
-4
lines changed
active-record/src/main/java/com/iluwatar/activerecord Expand file tree Collapse file tree 4 files changed +25
-4
lines changed Original file line number Diff line number Diff line change 5
5
import lombok .extern .slf4j .Slf4j ;
6
6
import org .h2 .jdbcx .JdbcDataSource ;
7
7
8
+ /**
9
+ * The amin application for the manual testing purposes.
10
+ */
8
11
@ Slf4j
9
12
public class App {
10
13
@@ -28,7 +31,12 @@ public class App {
28
31
+ " CONSTRAINT customer_id_fk FOREIGN KEY (customer_id) REFERENCES customer (id)\n "
29
32
+ ")" ;
30
33
31
-
34
+ /**
35
+ * Java main method to execute all the logic out there.
36
+ *
37
+ * @param args arguments.
38
+ * @throws Exception Any sort of exception that have to be picked up by the JVM.
39
+ */
32
40
public static void main (final String [] args ) throws Exception {
33
41
final var dataSource = createDataSource ();
34
42
createSchema (dataSource );
@@ -48,7 +56,7 @@ private static void executeOperation() {
48
56
order .setId (1L );
49
57
order .setOrderNumber ("O123" );
50
58
51
- // customer.addOrder(order);
59
+ // customer.addOrder(order);
52
60
customer .save ();
53
61
54
62
LOGGER .info ("The customer data by ID={}" , customer .findById (1L ));
Original file line number Diff line number Diff line change 8
8
import lombok .Setter ;
9
9
import lombok .ToString ;
10
10
11
+ /**
12
+ * The customer domain model.
13
+ */
11
14
@ Getter
12
15
@ Setter
13
16
@ ToString
Original file line number Diff line number Diff line change 6
6
import lombok .NoArgsConstructor ;
7
7
import lombok .Setter ;
8
8
9
+ /**
10
+ * An order domain model.
11
+ */
9
12
@ Getter
10
13
@ Setter
11
14
@ EqualsAndHashCode (onlyExplicitlyIncluded = true )
Original file line number Diff line number Diff line change 11
11
import lombok .RequiredArgsConstructor ;
12
12
import lombok .Setter ;
13
13
14
+ /**
15
+ * An active record base supposed to hold all the necessary active record pattern logic.
16
+ *
17
+ * @param <T> an active record type.
18
+ */
14
19
@ RequiredArgsConstructor
15
20
public abstract class RecordBase <T extends RecordBase <?>> {
16
21
@@ -117,8 +122,10 @@ private String constructFindByIdQuery() {
117
122
private T getDeclaredClassInstance () {
118
123
try {
119
124
return clazz .getDeclaredConstructor ().newInstance ();
120
- } catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException |
121
- InstantiationException e ) {
125
+ } catch (InvocationTargetException
126
+ | NoSuchMethodException
127
+ | IllegalAccessException
128
+ | InstantiationException e ) {
122
129
throw new IllegalStateException (
123
130
"Unable to create a new instance of the class=" + clazz .getName (), e );
124
131
}
You can’t perform that action at this time.
0 commit comments