forked from iluwatar/java-design-patterns
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
provide an initial implementation - not tested (iluwatar#79)
- Loading branch information
1 parent
8940396
commit 33aecdc
Showing
2 changed files
with
94 additions
and
12 deletions.
There are no files selected for viewing
25 changes: 13 additions & 12 deletions
25
active-record/src/main/java/com/iluwatar/activerecord/Customer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,38 @@ | ||
package com.iluwatar.activerecord; | ||
|
||
import java.sql.ResultSet; | ||
import java.util.List; | ||
import lombok.EqualsAndHashCode; | ||
import javax.sql.DataSource; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@RequiredArgsConstructor | ||
@EqualsAndHashCode(onlyExplicitlyIncluded = true) | ||
public class Customer { | ||
public class Customer extends RecordBase { | ||
|
||
private Long id; | ||
private String customerNumber; | ||
private String firstName; | ||
private String lastName; | ||
private List<Order> orders; | ||
|
||
public Customer findById(Long id) { | ||
return new Customer(); | ||
public Customer(DataSource dataSource) { | ||
super(dataSource); | ||
} | ||
|
||
public Customer findByNumber(String customerNumber) { | ||
return new Customer(); | ||
// TODO | ||
return null; | ||
// return new Customer(); | ||
} | ||
|
||
public List<Customer> findAll() { | ||
return List.of(); | ||
@Override | ||
protected String getTableName() { | ||
return "customer"; | ||
} | ||
|
||
public void save(Customer customer) { | ||
@Override | ||
protected void setFieldsFromResultSet(ResultSet rs) { | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters