diff --git a/03/src/de/dis2013/core/ImmoService.java b/03/src/de/dis2013/core/ImmoService.java index d4c9692..f215979 100644 --- a/03/src/de/dis2013/core/ImmoService.java +++ b/03/src/de/dis2013/core/ImmoService.java @@ -3,6 +3,7 @@ package de.dis2013.core; import java.util.Date; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import java.util.Set; import org.hibernate.Session; @@ -38,6 +39,14 @@ public class ImmoService { public ImmoService() { sessionFactory = new Configuration().configure().buildSessionFactory(); + //Open Hibernate Session + Session session = sessionFactory.openSession(); + //GetAll EstateAgents from DB + session.beginTransaction(); + List l = session.createCriteria(Makler.class).list(); + System.out.println(l.size()+" Makler gefunden."); + makler = new HashSet(l); + session.getTransaction().commit(); } /** @@ -108,10 +117,11 @@ public class ImmoService { public void addMakler(Makler m) { //Open Hibernate Session Session session = sessionFactory.openSession(); - + //Add EstateAgent to DB session.beginTransaction(); session.save(m); session.getTransaction().commit(); + //Add EstateAgent to local buffer makler.add(m); } @@ -120,6 +130,13 @@ public class ImmoService { * @param m Der Makler */ public void deleteMakler(Makler m) { + //Open Hibernate Session + Session session = sessionFactory.openSession(); + //Delete EstateAgent from DB + session.beginTransaction(); + session.delete(m); + session.getTransaction().commit(); + //Delete EstateAgent from local buffer makler.remove(m); } @@ -509,4 +526,13 @@ public class ImmoService { mv.setDauer(36); this.addMietvertrag(mv); } + + public void editEstateAgent(Makler m) { + //Open Hibernate Session + Session session = sessionFactory.openSession(); + //Update EstateAgent from DB + session.beginTransaction(); + session.merge(m); + session.getTransaction().commit(); + } } diff --git a/03/src/de/dis2013/data/mapping/Immobilie.hbm.xml b/03/src/de/dis2013/data/mapping/Immobilie.hbm.xml index 101d8b1..7ef0c04 100644 --- a/03/src/de/dis2013/data/mapping/Immobilie.hbm.xml +++ b/03/src/de/dis2013/data/mapping/Immobilie.hbm.xml @@ -7,12 +7,12 @@ - - - - - - + + + + + + diff --git a/03/src/de/dis2013/data/mapping/Makler.hbm.xml b/03/src/de/dis2013/data/mapping/Makler.hbm.xml index 7a289a2..b47267c 100644 --- a/03/src/de/dis2013/data/mapping/Makler.hbm.xml +++ b/03/src/de/dis2013/data/mapping/Makler.hbm.xml @@ -8,13 +8,8 @@ - + - - - - - - + \ No newline at end of file diff --git a/03/src/de/dis2013/data/mapping/Person.hbm.xml b/03/src/de/dis2013/data/mapping/Person.hbm.xml index 66707e5..475ac5d 100644 --- a/03/src/de/dis2013/data/mapping/Person.hbm.xml +++ b/03/src/de/dis2013/data/mapping/Person.hbm.xml @@ -7,8 +7,8 @@ - - - + + + \ No newline at end of file diff --git a/03/src/de/dis2013/editor/MaklerEditor.java b/03/src/de/dis2013/editor/MaklerEditor.java index 07c243f..2b52719 100644 --- a/03/src/de/dis2013/editor/MaklerEditor.java +++ b/03/src/de/dis2013/editor/MaklerEditor.java @@ -99,6 +99,8 @@ public class MaklerEditor { m.setLogin(new_login); if(!new_password.equals("")) m.setPasswort(new_password); + + service.editEstateAgent(m); } }