Skip to content

Commit

Permalink
make order an active record class as well + javadoc (iluwatar#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergejsvisockis committed Apr 15, 2024
1 parent ad80931 commit 1b8217c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
23 changes: 20 additions & 3 deletions active-record/src/main/java/com/iluwatar/activerecord/Order.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -11,11 +13,26 @@
*/
@Getter
@Setter
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@NoArgsConstructor
@AllArgsConstructor
public class Order {
public class Order extends RecordBase<Order> {

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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

/**
* An active record base supposed to hold all the necessary active record pattern logic.
* <p>
* This is the base class which is supposed to be extended by all the domain models that are
* expected to be persistent.
*
* @param <T> an active record type.
*/
Expand Down

0 comments on commit 1b8217c

Please sign in to comment.