I do not find any topics on my problem. After I change some field (i.e. "address"),and then update it to db. then content in db are changed. For example ,original:address = "room" ,current :address="room2". After I press update,the value displayed in webpage and database are correct. then I go to another page to view the result, the value changed back to original. When I refresh the page, it changed to current value(correct),and refresh again,it changed to original value(incorrect). The value changed every othertime when I refresh the page.
what's the reason? how to settle it?
Even terrible , when I delete an object, the other time when I refresh the view page, it display and disappear!
I think it is something with the session operation.
I do it with session.flush()/session.clear(),still no effect.
the mapping file:
Code:
<hibernate-mapping>
<class name="com.xunan.sitexa.site.data.Site" table="T_Site" schema="dbo" catalog="sitexa">
<id name="siteId" type="java.lang.String">
<column name="SiteId" length="50"/>
<generator class="assigned"/>
</id>
<many-to-one name="type" class="com.xunan.sitexa.site.data.SiteType" update="true" insert="true">
<column name="TypeId" length="50" not-null="true"/>
</many-to-one>
<many-to-one name="parent" class="com.xunan.sitexa.site.data.Site" update="true" insert="true">
<column name="ParentId" length="50"/>
</many-to-one>
<property name="name" type="java.lang.String">
<column name="Name" length="200"/>
</property>
<property name="createDate" type="java.util.Date">
<column name="CreateDate" length="23"/>
</property>
<property name="address" type="java.lang.String">
<column name="Address" length="500"/>
</property>
<property name="status" type="java.lang.Boolean">
<column name="Status" length="1" not-null="true"/>
</property>
<many-to-one name="governor" class="com.xunan.sitexa.user.data.Member">
<column name="Governor" length="50"/>
</many-to-one>
<property name="introduction" type="java.lang.String">
<column name="Introduction" length="1000"/>
</property>
<property name="longitude" type="java.lang.Float">
<column name="Longitude"/>
</property>
<property name="latitude" type="java.lang.Float">
<column name="Latitude"/>
</property>
<property name="zoom" type="java.lang.Integer">
<column name="Zoom"/>
</property>
<property name="vwCnt" type="java.lang.Integer">
<column name="VwCnt"/>
</property>
<set name="properties" inverse="true" order-by="propId">
<key>
<column name="SiteId" length="50" not-null="true"/>
</key>
<one-to-many class="com.xunan.sitexa.site.data.SiteProperty"/>
</set>
<set name="pictures" inverse="true" order-by="picId">
<key>
<column name="SiteId" length="50" not-null="true"/>
</key>
<one-to-many class="com.xunan.sitexa.site.data.SitePicture"/>
</set>
<set name="children" inverse="true" order-by="siteId">
<key>
<column name="ParentId" length="50" not-null="true"/>
</key>
<one-to-many class="com.xunan.sitexa.site.data.Site"/>
</set>
<set name="members" inverse="true" order-by="siteId">
<key>
<column name="SiteId" length="50" not-null="true"/>
</key>
<one-to-many class="com.xunan.sitexa.site.data.SiteMember"/>
</set>
</class>
</hibernate-mapping>
and the DAO class
Code:
public Session getSession() {
if (null == this.session)
session = HibernateSessionFactory.getSession();
return session;
}
protected void delete(Object object) {
Transaction tx = session.beginTransaction();
tx.begin();
session.delete(object);
tx.commit();
session.flush();
session.clear();
}
protected void save(Object object) {
Transaction tx = session.beginTransaction();
tx.begin();
session.save(object);
tx.commit();
}
protected void update(Object object) {
Transaction tx = session.beginTransaction();
tx.begin();
session.update(object);
tx.commit();
}
protected void saveOrUpdate(Object object) {
Transaction tx = session.beginTransaction();
tx.begin();
session.saveOrUpdate(object);
tx.commit();
}