-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: session.save(), .delete() und .update() haben keinen Effekt
PostPosted: Fri May 22, 2009 11:04 am 
Newbie

Joined: Fri May 22, 2009 10:56 am
Posts: 2
Hallo,

solangsam bin ich am verzweifeln. Ich verwende für ein Projekt Hibernate mit Tapestry 5 zusammen und bekomme einfach keine Änderungen in der Datenbank auf die Reihe.

Wenn ich zum Beispiel versuche, einen User zu registrieren und dann dessen Kundendaten, Logindaten und Adressen in die Datenbank schreiben will, bekomme ich zwar von Hibernate folgende Infos:
Code:
[DEBUG] hibernate.SQL insert into rgp.Logindaten (name, passwort) values (?, ?)
Hibernate: insert into rgp.Logindaten (name, passwort) values (?, ?)
[DEBUG] hibernate.SQL insert into rgp.Adressen (strasse, nr, plz, ort, land) values (?, ?, ?, ?, ?)
Hibernate: insert into rgp.Adressen (strasse, nr, plz, ort, land) values (?, ?, ?, ?, ?)
[DEBUG] hibernate.SQL insert into rgp.Kundendaten (loginid, rechnungsadresse, lieferadresse, anrede, titel, name, vorname, email_adresse) values (?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into rgp.Kundendaten (loginid, rechnungsadresse, lieferadresse, anrede, titel, name, vorname, email_adresse) values (?, ?, ?, ?, ?, ?, ?, ?)

Auf die neue Zeile in der DB kann ich aber lange warten.
Das selbe Problem habe ich bei update und delete. Lauf Hibernate wurde es durchgeführt, aber irgendwie nicht in der DB übernommen.
Ein manuelles .flush() nach dem Befehl bringt leider auch nichts.

Das hier ist der Teil, in dem der Aufruf über den RegistrierenButton gestartet wird:
Code:
import org.hibernate.Session;

@Inject
    private Session hibernate;


    private Object onSuccessFromRegisterForm() {
        ....
            try {
                hibernate.save(kunde);
            } catch (Exception e) {
                e.printStackTrace();
                this.registerForm.recordError(messages.get("hibernate-error"));
                return null;
            }...
        return null;
    }


Habe ich einen Denkfehler in der Verwendung der @Inject Session? Muss ihc mich da doch um irgendwas kümmern?
Würde mich riesig freuen, wenn mir hier jemand helfen kann, falls noch was fehlt, einfach melden!
Danke
Alex


Hier mal die Mappings:
Code:
<hibernate-mapping>
  <class catalog="rgp" name="org.norf2k.rgp.hibernate.elements.Kundendaten" table="Kundendaten">
    <id name="kundennummer" type="java.lang.Integer">
      <column name="kundennummer"/>
      <generator class="identity"/>
    </id>
    <many-to-one cascade="save-update" class="org.norf2k.rgp.hibernate.elements.Logindaten" fetch="select" name="logindaten">
      <column name="loginid" not-null="true"/>
    </many-to-one>
    <many-to-one cascade="save-update" class="org.norf2k.rgp.hibernate.elements.Adressen" fetch="select" name="adressenByRechnungsadresse">
      <column name="rechnungsadresse" not-null="true"/>
    </many-to-one>
    <many-to-one cascade="save-update" class="org.norf2k.rgp.hibernate.elements.Adressen" fetch="select" name="adressenByLieferadresse">
      <column name="lieferadresse" not-null="true"/>
    </many-to-one>
    <many-to-one class="org.norf2k.rgp.hibernate.elements.Rabattstufe" fetch="select" insert="false" name="rabattstufe">
      <column name="rabattstufe"/>
    </many-to-one>
    <property name="anrede" type="string">
      <column length="65535" name="anrede" not-null="true"/>
    </property>
    <property name="titel" type="string">
      <column length="65535" name="titel"/>
    </property>
    <property name="name" type="string">
      <column length="65535" name="name" not-null="true"/>
    </property>
    <property name="vorname" type="string">
      <column length="65535" name="vorname" not-null="true"/>
    </property>
    <property name="emailAdresse" type="string">
      <column length="65535" name="email_adresse" not-null="true"/>
    </property>
    <set inverse="true" name="bestellungens">
      <key>
        <column name="kundennummer" not-null="true"/>
      </key>
      <one-to-many class="org.norf2k.rgp.hibernate.elements.Bestellungen"/>
    </set>
  </class>
</hibernate-mapping>


Code:
<hibernate-mapping>
  <class catalog="rgp" name="org.norf2k.rgp.hibernate.elements.Logindaten" table="Logindaten">
    <id name="id" type="java.lang.Integer">
      <column name="id"/>
      <generator class="identity"/>
    </id>
    <many-to-one class="org.norf2k.rgp.hibernate.elements.Gruppe" fetch="select" insert="false" lazy="false" name="gruppe">
      <column name="gruppe" not-null="true"/>
    </many-to-one>
    <property name="name" type="string">
      <column length="65535" name="name" not-null="true"/>
    </property>
    <property name="passwort" type="string">
      <column length="65535" name="passwort" not-null="true"/>
    </property>
    <set inverse="true" name="kundendatens">
      <key>
        <column name="loginid" not-null="true"/>
      </key>
      <one-to-many class="org.norf2k.rgp.hibernate.elements.Kundendaten"/>
    </set>
  </class>
</hibernate-mapping>


Code:
<hibernate-mapping>
  <class catalog="rgp" name="org.norf2k.rgp.hibernate.elements.Adressen" table="Adressen">
    <id name="adressennummer" type="java.lang.Integer">
      <column name="adressennummer"/>
      <generator class="identity"/>
    </id>
    <property name="strasse" type="string">
      <column length="65535" name="strasse" not-null="true"/>
    </property>
    <property name="nr" type="int">
      <column name="nr" not-null="true"/>
    </property>
    <property name="plz" type="int">
      <column name="plz" not-null="true"/>
    </property>
    <property name="ort" type="string">
      <column length="65535" name="ort" not-null="true"/>
    </property>
    <property name="land" type="string">
      <column length="65535" name="land" not-null="true"/>
    </property>
    <set inverse="true" name="bestellungensForLieferadresse">
      <key>
        <column name="lieferadresse" not-null="true"/>
      </key>
      <one-to-many class="org.norf2k.rgp.hibernate.elements.Bestellungen"/>
    </set>
    <set inverse="true" name="bestellungensForRechnungsadresse">
      <key>
        <column name="rechnungsadresse" not-null="true"/>
      </key>
      <one-to-many class="org.norf2k.rgp.hibernate.elements.Bestellungen"/>
    </set>
    <set inverse="true" name="kundendatensForRechnungsadresse">
      <key>
        <column name="rechnungsadresse" not-null="true"/>
      </key>
      <one-to-many class="org.norf2k.rgp.hibernate.elements.Kundendaten"/>
    </set>
    <set inverse="true" name="kundendatensForLieferadresse">
      <key>
        <column name="lieferadresse" not-null="true"/>
      </key>
      <one-to-many class="org.norf2k.rgp.hibernate.elements.Kundendaten"/>
    </set>
  </class>
</hibernate-mapping>


Code:
<hibernate-configuration>
  <session-factory>
    <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="hibernate.connection.url">jdbc:mysql://...</property>
    <property name="hibernate.connection.username">...</property>
    <property name="hibernate.connection.password">...</property>
    <property name="hibernate.current_session_context_class">thread</property>
    <property name="hibernate.show_sql">true</property>
    <mapping resource="/Adressen.hbm.xml"/>
    <mapping resource="/Bestellposten.hbm.xml"/>
    <mapping resource="/Logindaten.hbm.xml"/>
    <mapping resource="/Verpackung.hbm.xml"/>
    <mapping resource="/Artikelgruppe.hbm.xml"/>
    <mapping resource="/Bestellungen.hbm.xml"/>
    <mapping resource="/Artikeldaten.hbm.xml"/>
    <mapping resource="/Kundendaten.hbm.xml"/>
    <mapping resource="/Bestellstatus.hbm.xml"/>
    <mapping resource="/Rabattstufe.hbm.xml"/>
    <mapping resource="/Gruppe.hbm.xml"/>
  </session-factory>
</hibernate-configuration>


Top
 Profile  
 
 Post subject: Re: session.save(), .delete() und .update() haben keinen Effekt
PostPosted: Wed May 27, 2009 3:53 pm 
Expert
Expert

Joined: Thu Jul 05, 2007 9:38 am
Posts: 287
Du musst noch ein commit machen, das scheint in dem code zu fehlen

_________________
Please rate useful posts.


Schauderhaft: Softwaredevelopment, Projectmanagement, Qualitymanagement and all things "schauderhaft"


Top
 Profile  
 
 Post subject: Re: session.save(), .delete() und .update() haben keinen Effekt
PostPosted: Wed May 27, 2009 4:35 pm 
Newbie

Joined: Fri May 22, 2009 10:56 am
Posts: 2
Hallo,

Ich habe heute mal testweise den TapestrySessionManager injected und da gab es dann auch die commit Funktion und alles klappt!
Vielen Dank für die Antwort!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.