Further changes to fit our DB schema
Further changes to fit our DB schema Added session.close() to add delete and edit EstateAgent
This commit is contained in:
parent
9b2fa48271
commit
990a7811eb
|
@ -46,7 +46,7 @@ public class Main {
|
|||
MaklerAuthenticator ma = new MaklerAuthenticator(service);
|
||||
|
||||
//Testdaten
|
||||
//service.addTestData();
|
||||
service.addTestData();
|
||||
|
||||
//Verarbeite Eingabe
|
||||
while(true) {
|
||||
|
|
|
@ -47,6 +47,7 @@ public class ImmoService {
|
|||
System.out.println(l.size()+" Makler gefunden.");
|
||||
makler = new HashSet<Makler>(l);
|
||||
session.getTransaction().commit();
|
||||
session.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -121,6 +122,7 @@ public class ImmoService {
|
|||
session.beginTransaction();
|
||||
session.save(m);
|
||||
session.getTransaction().commit();
|
||||
session.close();
|
||||
//Add EstateAgent to local buffer
|
||||
makler.add(m);
|
||||
}
|
||||
|
@ -136,6 +138,7 @@ public class ImmoService {
|
|||
session.beginTransaction();
|
||||
session.delete(m);
|
||||
session.getTransaction().commit();
|
||||
session.close();
|
||||
//Delete EstateAgent from local buffer
|
||||
makler.remove(m);
|
||||
}
|
||||
|
@ -410,11 +413,7 @@ public class ImmoService {
|
|||
* Fügt einige Testdaten hinzu
|
||||
*/
|
||||
public void addTestData() {
|
||||
//Hibernate Session erzeugen
|
||||
Session session = sessionFactory.openSession();
|
||||
|
||||
session.beginTransaction();
|
||||
|
||||
|
||||
Makler m = new Makler();
|
||||
m.setName("Max Mustermann");
|
||||
m.setAdresse("Am Informatikum 9");
|
||||
|
@ -423,9 +422,9 @@ public class ImmoService {
|
|||
|
||||
//TODO: Dieser Makler wird im Speicher und der DB gehalten
|
||||
this.addMakler(m);
|
||||
session.save(m);
|
||||
session.getTransaction().commit();
|
||||
|
||||
//Hibernate Session erzeugen
|
||||
Session session = sessionFactory.openSession();
|
||||
session.beginTransaction();
|
||||
|
||||
Person p1 = new Person();
|
||||
|
@ -471,12 +470,12 @@ public class ImmoService {
|
|||
session.beginTransaction();
|
||||
Makler m2 = (Makler)session.get(Makler.class, m.getId());
|
||||
Set<Immobilie> immos = m2.getImmobilien();
|
||||
Iterator<Immobilie> it = immos.iterator();
|
||||
/*Iterator<Immobilie> it = immos.iterator();
|
||||
|
||||
while(it.hasNext()) {
|
||||
Immobilie i = it.next();
|
||||
System.out.println("Immo: "+i.getOrt());
|
||||
}
|
||||
}*/
|
||||
session.close();
|
||||
|
||||
Wohnung w = new Wohnung();
|
||||
|
@ -534,5 +533,6 @@ public class ImmoService {
|
|||
session.beginTransaction();
|
||||
session.merge(m);
|
||||
session.getTransaction().commit();
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
||||
<hibernate-mapping>
|
||||
<class name="de.dis2013.data.Immobilie" abstract="true">
|
||||
<class name="de.dis2013.data.Immobilie" table="estate">
|
||||
<id name="id" column="id">
|
||||
<generator class="increment" />
|
||||
</id>
|
||||
|
@ -12,19 +12,21 @@
|
|||
<property name="strasse" type="string" column="street" />
|
||||
<property name="hausnummer" type="string" column="streetnumber" />
|
||||
<property name="flaeche" type="integer" column="squarearea" />
|
||||
<property name="verwalter" type="integer" column="agent" not-null="true" />
|
||||
<many-to-one name="verwalter" class="de.dis2013.data.Makler" column="agent" not-null="true" />
|
||||
|
||||
<union-subclass name="de.dis2013.data.Haus" table="house">
|
||||
<joined-subclass name="de.dis2013.data.Haus" table="house">
|
||||
<key column="id"/>
|
||||
<property name="stockwerke" type="integer" column="floors" />
|
||||
<property name="kaufpreis" type="integer" column="price" />
|
||||
<property name="garten" type="boolean" column="garden" />
|
||||
</union-subclass>
|
||||
<union-subclass name="de.dis2013.data.Wohnung" table="apartment">
|
||||
</joined-subclass>
|
||||
<joined-subclass name="de.dis2013.data.Wohnung" table="apartment">
|
||||
<key column="id"/>
|
||||
<property name="stockwerk" type="integer" column="floor" />
|
||||
<property name="mietpreis" type="integer" column="rent" />
|
||||
<property name="zimmer" type="integer" column="rooms" />
|
||||
<property name="balkon" type="boolean" column="balcony" />
|
||||
<property name="ebk" type="boolean" column="builtinkitchen" />
|
||||
</union-subclass>
|
||||
</joined-subclass>
|
||||
</class>
|
||||
</hibernate-mapping>
|
Loading…
Reference in New Issue