From 1b8217c0bfa098a09e7f415e34e2d5438c1f1347 Mon Sep 17 00:00:00 2001 From: Sergejs Visockis Date: Fri, 29 Mar 2024 20:06:39 +0100 Subject: [PATCH] make order an active record class as well + javadoc (#79) --- .../java/com/iluwatar/activerecord/Order.java | 23 ++++++++++++++++--- .../com/iluwatar/activerecord/RecordBase.java | 3 +++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/active-record/src/main/java/com/iluwatar/activerecord/Order.java b/active-record/src/main/java/com/iluwatar/activerecord/Order.java index 4d77b90fcbe3..0e151bb11b93 100644 --- a/active-record/src/main/java/com/iluwatar/activerecord/Order.java +++ b/active-record/src/main/java/com/iluwatar/activerecord/Order.java @@ -1,7 +1,9 @@ package com.iluwatar.activerecord; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; import lombok.AllArgsConstructor; -import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -11,11 +13,26 @@ */ @Getter @Setter -@EqualsAndHashCode(onlyExplicitlyIncluded = true) @NoArgsConstructor @AllArgsConstructor -public class Order { +public class Order extends RecordBase { private Long id; private String orderNumber; + + @Override + protected String getTableName() { + return "order"; + } + + @Override + protected void setFieldsFromResultSet(ResultSet rs) throws SQLException { + this.id = rs.getLong("id"); + this.orderNumber = rs.getString("order_number"); + } + + @Override + protected void setPreparedStatementParams(PreparedStatement pstmt) throws SQLException { + // TODO + } } diff --git a/active-record/src/main/java/com/iluwatar/activerecord/RecordBase.java b/active-record/src/main/java/com/iluwatar/activerecord/RecordBase.java index c1b315b4d7b1..3cf974d207d1 100644 --- a/active-record/src/main/java/com/iluwatar/activerecord/RecordBase.java +++ b/active-record/src/main/java/com/iluwatar/activerecord/RecordBase.java @@ -13,6 +13,9 @@ /** * An active record base supposed to hold all the necessary active record pattern logic. + *

+ * This is the base class which is supposed to be extended by all the domain models that are + * expected to be persistent. * * @param an active record type. */