-->
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.  [ 5 posts ] 
Author Message
 Post subject: why hibernate update data after selected?
PostPosted: Sun Aug 14, 2005 1:41 am 
Newbie

Joined: Sun Aug 14, 2005 1:30 am
Posts: 4
Hibernate version:2.1


when i load or query a project or user, hibernate will auto update the project or user which was loaded by select.

why?


Mapping Documents:
User.hbm.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
   <class name="com.skysuite.beans.User" table="users">
     <cache usage="read-write"/>
      <id column="ID" length="13" name="id" type="long" unsaved-value="null">
         <generator class="net.sf.hibernate.id.TableCustomGenerator">
            <param name="table">id_manager</param>
            <param name="column">IDValue</param>
            <param name="id">8</param>
            <param name="increment">15</param>
         </generator>
      </id>
      <property column="username" length="20" name="username" type="string" not-null="true" unique="true"/>
      <property column="password" length="32" name="password" type="string"/>
      <property column="fullname" length="50" name="fullname" type="string"/>
      <property column="email" length="50" name="email" type="string" not-null="true" unique="true"/>
      <property column="createDate" length="20" name="createDate" type="net.sf.hibernate.type.DateLongType"/>
      <property column="modifyDate" length="13" name="modifyDate" type="net.sf.hibernate.type.DateLongType"/>
      <property column="isLogin" length="1" name="isLogin" type="boolean" not-null="true"/>
      <property column="lastLoginDate" length="13" name="lastLoginDate" type="net.sf.hibernate.type.DateLongType"/>
      <property column="lastLoginIP" length="255" name="lastLoginIP" type="string"/>
   </class>
</hibernate-mapping>


Project.hbm.xml

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
   <class name="com.skysuite.beans.Project" table="project">
   <cache usage="read-write"/>
      <id column="ID" length="13" name="id" type="long" unsaved-value="null">
         <generator class="net.sf.hibernate.id.TableCustomGenerator">
            <param name="table">id_manager</param>
            <param name="column">IDValue</param>
            <param name="id">7</param>
            <param name="increment">15</param>
         </generator>
      </id>
      <property column="name" length="255" name="name" type="string"/>
      <property column="mysummary" length="255" name="summary" type="net.sf.hibernate.type.StringClobType"/>
      <property column="par_id" length="13" name="par_id" type="long" insert="false" update="false"/>   
      <property column="write_time" length="13" name="write_time" type="net.sf.hibernate.type.DateLongType"/>
      <property column="click_times" length="6" name="click_times" type="long"/>
      <property column="doc_count" length="6" name="doc_count" type="long"/>
      <property column="reback_count" length="6" name="reback_count" type="long"/>
      <property column="isPublish" length="1" name="isPublish" type="boolean"/>
      <many-to-one name="writer" column="writer" class="com.skysuite.beans.User" not-null="true" cascade="none" outer-join="true"/>
      <many-to-one name="parent" column="par_id" class="com.skysuite.beans.Project" cascade="none"/>
      <bag name="document" table="document" lazy="true" inverse="true"
         cascade="delete" order-by="write_time desc">
      
         <key column="proj_id" />
         <one-to-many class="com.skysuite.beans.Document" />
      </bag>
      <bag name="children" table="project" lazy="true" inverse="true"
         cascade="delete" order-by="write_time desc">
      
         <key column="par_id" />
         <one-to-many class="com.skysuite.beans.Project" />
      </bag>
      <bag name="posts" table="projectPost" lazy="true" inverse="true"
         cascade="delete" where="par_id=id" order-by="send_time desc">
      
         <key column="dest_id" />
         <one-to-many class="com.skysuite.beans.ProjectPost" />
      </bag>
   </class>
</hibernate-mapping>

_________________
hibernate i love it!


Top
 Profile  
 
 Post subject: also like say this:
PostPosted: Sun Aug 14, 2005 1:53 am 
Newbie

Joined: Sun Aug 14, 2005 1:30 am
Posts: 4
sample as:
in the console i can see two sql sentences:

Quote:
Hibernate: select uservo0_.ID as ID0_, uservo0_.username as username0_, uservo0_.password as password0_, uservo0_.fullname as fullname0_, uservo0_.email as email0_, uservo0_.createDate as createDate0_, uservo0_.modifyDate as modifyDate0_, uservo0_.isLogin as isLogin0_, uservo0_.lastLoginDate as lastLogi9_0_, uservo0_.lastLoginIP as lastLog10_0_ from users uservo0_ where uservo0_.ID=?

2005-08-14 13:43:35,481 [org.springframework.orm.hibernate.HibernateTransactionManager]-[INFO] Initiating transaction commit

Hibernate: update users set username=?, password=?, fullname=?, email=?, createDate=?, modifyDate=?, isLogin=?, lastLoginDate=?, lastLoginIP=? where ID=?

2005-08-14 13:43:35,517 [org.springframework.orm.hibernate.HibernateTransactionManager]-[INFO] Initiating transaction commit


they appear at the same time. help me ,how can i deal with it?


thanks.

_________________
hibernate i love it!


Top
 Profile  
 
 Post subject: this has been resoled.
PostPosted: Tue Aug 23, 2005 3:04 am 
Newbie

Joined: Sun Aug 14, 2005 1:30 am
Posts: 4
this has been resoled.

The transaction configuration was error.

sorry

_________________
hibernate i love it!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 25, 2005 6:53 pm 
Regular
Regular

Joined: Tue Nov 09, 2004 5:15 pm
Posts: 100
Hi,

I'm facing the same problem. Can you please tell me what exactly was the problem?

Thanks in advance!


Top
 Profile  
 
 Post subject: this happended in the spring
PostPosted: Mon Aug 29, 2005 10:13 am 
Newbie

Joined: Sun Aug 14, 2005 1:30 am
Posts: 4
<bean id="baseTransactionProxy"
class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="transactionAttributes">
<prop key=".*add.*">PROPAGATION_REQUIRED</prop>
<prop key=".*del.*">PROPAGATION_REQUIRED</prop>
<prop key=".*update.*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_REQUIRED</prop> </property>
</bean>

i changed this to:

<prop key="*add*">PROPAGATION_REQUIRED</prop>
<prop key="*del*">PROPAGATION_REQUIRED</prop>
<prop key="*update*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>



this is ok!

try it!


i used the spring to control transaction.

_________________
hibernate i love it!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.