#107 Dao example JavaDoc
This commit is contained in:
parent
a7d25e0485
commit
3526d96e37
@ -7,9 +7,14 @@ import java.util.List;
|
||||
*
|
||||
* With the DAO pattern, we can use various method calls to retrieve/add/delete/update data without directly
|
||||
* interacting with the data. The below example demonstrates basic operations(CRUD): select, add, update, and delete.
|
||||
*
|
||||
*/
|
||||
public class App {
|
||||
|
||||
/**
|
||||
* Program entry point
|
||||
* @param args command line args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
||||
CustomerDaoImpl customerDao = new CustomerDaoImpl(generateSampleCustomers());
|
||||
@ -33,6 +38,10 @@ public class App {
|
||||
System.out.println("customerDao.getAllCustomers(): " + customerDao.getAllCustomers());
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate customers
|
||||
* @return list of customers
|
||||
*/
|
||||
public static List<Customer> generateSampleCustomers() {
|
||||
Customer customer1 = new Customer(1, "Adam", "Adamson");
|
||||
Customer customer2 = new Customer(2, "Bob", "Bobson");
|
||||
|
@ -1,6 +1,12 @@
|
||||
package com.iluwatar.dao;
|
||||
|
||||
/**
|
||||
*
|
||||
* Customer
|
||||
*
|
||||
*/
|
||||
public class Customer {
|
||||
|
||||
private int id;
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
|
@ -2,7 +2,13 @@ package com.iluwatar.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* CustomerDao
|
||||
*
|
||||
*/
|
||||
public interface CustomerDao {
|
||||
|
||||
public List<Customer> getAllCustomers();
|
||||
public Customer getCusterById(int id);
|
||||
public void addCustomer(Customer customer);
|
||||
|
@ -3,11 +3,13 @@ package com.iluwatar.dao;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* The data access object (DAO) is an object that provides an abstract interface to some type of database or other persistence mechanism.
|
||||
* By mapping application calls to the persistence layer, DAO provide some specific data operations without exposing details of the database.
|
||||
* This isolation supports the Single responsibility principle. It separates what data accesses the application needs, in terms of
|
||||
* domain-specific objects and data types (the public interface of the DAO), from how these needs can be satisfied with a specific DBMS,
|
||||
* database schema, etc.
|
||||
*
|
||||
*/
|
||||
public class CustomerDaoImpl implements CustomerDao {
|
||||
|
||||
|
@ -4,6 +4,11 @@ import org.junit.Test;
|
||||
|
||||
import com.iluwatar.dao.App;
|
||||
|
||||
/**
|
||||
*
|
||||
* Application test
|
||||
*
|
||||
*/
|
||||
public class AppTest {
|
||||
|
||||
@Test
|
||||
|
Loading…
x
Reference in New Issue
Block a user