diff --git a/persistence/src/main/java/fr/gasser/daoexample/dao/Dao.java b/persistence/src/main/java/fr/gasser/daoexample/dao/Dao.java index fe3b9fe..44e746b 100644 --- a/persistence/src/main/java/fr/gasser/daoexample/dao/Dao.java +++ b/persistence/src/main/java/fr/gasser/daoexample/dao/Dao.java @@ -17,7 +17,7 @@ public abstract class Dao { public abstract T find(int id); - public abstract List findAll(T obj); + public abstract List findAll(); public abstract boolean update(T obj); diff --git a/persistence/src/main/java/fr/gasser/daoexample/dao/DaoAbstractFactory.java b/persistence/src/main/java/fr/gasser/daoexample/dao/DaoAbstractFactory.java index ad5b04b..0eab54b 100644 --- a/persistence/src/main/java/fr/gasser/daoexample/dao/DaoAbstractFactory.java +++ b/persistence/src/main/java/fr/gasser/daoexample/dao/DaoAbstractFactory.java @@ -1,5 +1,9 @@ package fr.gasser.daoexample.dao; +import fr.gasser.daoexample.model.Discipline; +import fr.gasser.daoexample.model.Student; +import fr.gasser.daoexample.model.Teacher; + public interface DaoAbstractFactory { static DaoAbstractFactory createFactory(FactoryType type) { @@ -18,10 +22,10 @@ public interface DaoAbstractFactory { return createFactory(FactoryType.DaoFactory); } - StudentDao createStudentDao(); + Dao createStudentDao(); - TeacherDao createTeacherDao(); + Dao createTeacherDao(); - DisciplineDao createDisciplineDao(); + Dao createDisciplineDao(); } diff --git a/persistence/src/main/java/fr/gasser/daoexample/dao/DaoFactory.java b/persistence/src/main/java/fr/gasser/daoexample/dao/DaoFactory.java index 606f263..77bc207 100644 --- a/persistence/src/main/java/fr/gasser/daoexample/dao/DaoFactory.java +++ b/persistence/src/main/java/fr/gasser/daoexample/dao/DaoFactory.java @@ -1,5 +1,8 @@ package fr.gasser.daoexample.dao; +import fr.gasser.daoexample.model.Discipline; +import fr.gasser.daoexample.model.Student; +import fr.gasser.daoexample.model.Teacher; import fr.gasser.daoexample.sql.Connection; import fr.gasser.daoexample.sql.DummyConnection; @@ -7,17 +10,17 @@ public class DaoFactory implements DaoAbstractFactory { private static Connection connection = new DummyConnection(); @Override - public StudentDao createStudentDao() { + public Dao createStudentDao() { return new StudentDao(DaoFactory.connection); } @Override - public TeacherDao createTeacherDao() { + public Dao createTeacherDao() { return new TeacherDao(DaoFactory.connection); } @Override - public DisciplineDao createDisciplineDao() { + public Dao createDisciplineDao() { return new DisciplineDao(DaoFactory.connection); } } diff --git a/persistence/src/main/java/fr/gasser/daoexample/dao/DisciplineDao.java b/persistence/src/main/java/fr/gasser/daoexample/dao/DisciplineDao.java index 61ac979..9f7fb25 100644 --- a/persistence/src/main/java/fr/gasser/daoexample/dao/DisciplineDao.java +++ b/persistence/src/main/java/fr/gasser/daoexample/dao/DisciplineDao.java @@ -31,7 +31,7 @@ public class DisciplineDao extends Dao { } @Override - public List findAll(Discipline obj) { + public List findAll() { return DISCIPLINES; } diff --git a/persistence/src/main/java/fr/gasser/daoexample/dao/StudentDao.java b/persistence/src/main/java/fr/gasser/daoexample/dao/StudentDao.java index 34b0c5c..50fad64 100644 --- a/persistence/src/main/java/fr/gasser/daoexample/dao/StudentDao.java +++ b/persistence/src/main/java/fr/gasser/daoexample/dao/StudentDao.java @@ -32,7 +32,7 @@ public class StudentDao extends Dao { } @Override - public List findAll(Student obj) { + public List findAll() { return students; } diff --git a/persistence/src/main/java/fr/gasser/daoexample/dao/TeacherDao.java b/persistence/src/main/java/fr/gasser/daoexample/dao/TeacherDao.java index 8becfa0..6e0d864 100644 --- a/persistence/src/main/java/fr/gasser/daoexample/dao/TeacherDao.java +++ b/persistence/src/main/java/fr/gasser/daoexample/dao/TeacherDao.java @@ -31,7 +31,7 @@ public class TeacherDao extends Dao { } @Override - public List findAll(Teacher obj) { + public List findAll() { return teachers; } diff --git a/persistence/src/main/java/fr/gasser/daoexample/model/Student.java b/persistence/src/main/java/fr/gasser/daoexample/model/Student.java index 3d2472e..98ffbd1 100644 --- a/persistence/src/main/java/fr/gasser/daoexample/model/Student.java +++ b/persistence/src/main/java/fr/gasser/daoexample/model/Student.java @@ -2,37 +2,45 @@ package fr.gasser.daoexample.model; public class Student extends Entity { - private String nom; - private String prenom; + private String name; + private String surname; public Student() { this(0, "", ""); } - public Student(int id, String nom, String prenom) { + public Student(int id, String name, String surname) { super(id); - this.nom = nom; - this.prenom = prenom; + this.name = name; + this.surname = surname; } public String getName() { - return nom; + return name; } - public void setNom(String nom) { - this.nom = nom; + public void setName(String name) { + this.name = name; } public String getSurname() { - return prenom; + return surname; } - public void setPrenom(String prenom) { - this.prenom = prenom; + public void setSurname(String surname) { + this.surname = surname; } + @Override + public String toString() { + return "Student{" + + "name='" + name + '\'' + + ", surname='" + surname + '\'' + + ", id=" + id + + '}'; + } } \ No newline at end of file diff --git a/persistence/src/main/java/fr/gasser/daoexample/sql/Connection.java b/persistence/src/main/java/fr/gasser/daoexample/sql/Connection.java index 36ac760..c610453 100644 --- a/persistence/src/main/java/fr/gasser/daoexample/sql/Connection.java +++ b/persistence/src/main/java/fr/gasser/daoexample/sql/Connection.java @@ -1,9 +1,11 @@ package fr.gasser.daoexample.sql; -public interface Connection { - void connect(); +import java.sql.SQLException; - void close(); +public interface Connection { + void connect() throws SQLException; + + void close() throws SQLException; java.sql.Connection getConnection(); }