-->
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.  [ 2 posts ] 
Author Message
 Post subject: Dirty checking - is it configurable?
PostPosted: Wed Mar 23, 2005 11:36 am 
Regular
Regular

Joined: Tue Nov 30, 2004 4:23 pm
Posts: 62
I am running tests out of the "Hibernate - A Developer's Notebook" and there is a Track class that has a few attributes and I updated one of those attributes (volume) within a session, after I have queried for all the Track classes within the database. With dirty checking, are all the fields supposed to show up in the update statement or is just the field that is modified? And is this occurring because I have not modified my configuration correctly?

SQL OUTPUT:
Code:
Hibernate: select track0_.TRACK_ID as TRACK_ID, track0_.title as title, track0_.filePath as filePath, track0_.playTime as playTime, track0_.added as added, track0_.volume as volume from TRACK track0_ where (track0_.volume<=? )
Hibernate: update TRACK set title=?, filePath=?, playTime=?, added=?, volume=? where TRACK_ID=?
Hibernate: update TRACK set title=?, filePath=?, playTime=?, added=?, volume=? where TRACK_ID=?
Hibernate: update TRACK set title=?, filePath=?, playTime=?, added=?, volume=? where TRACK_ID=?



Mapping File
Code:
<?xml version="1.0"?>
<!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.oreilly.hh.Track" table="TRACK">
    <meta attribute="class-description">
      Represents a single playable track in the music database.
      @author Jim Elliott (with help from Hibernate)
    </meta>

    <id name="id" type="int" column="TRACK_ID">
      <meta attribute="scope-set">protected</meta>
      <generator class="native"/>
    </id>

    <property name="title" type="string" not-null="true"/>

    <property name="filePath" type="string" not-null="true"/>

    <property name="playTime" type="time">
      <meta attribute="field-description">Playing time</meta>
    </property>

    <property name="added" type="date">
      <meta attribute="field-description">When the track was created</meta>
    </property>

    <property name="volume" type="short" not-null="true">
      <meta attribute="field-description">How loud to play the track</meta>
    </property>

  </class>

  <query name="com.oreilly.hh.tracksNoLongerThan">
    <![CDATA[
        from com.oreilly.hh.Track as track
        where track.playTime <= :length
      ]]>
  </query>

    <query name="com.oreilly.hh.tracksNoLouderThan">
    <![CDATA[
        from com.oreilly.hh.Track as track
        where track.volume <= :volume
      ]]>
  </query>

</hibernate-mapping>


Thanks

-jay
[/b]


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 27, 2005 5:05 am 
Senior
Senior

Joined: Sat Jul 17, 2004 5:16 pm
Posts: 143
I believe the default behavior or Hibernate is to update all columns if any has changed (this is usually more efficient anyway since the SQL exists and might be compiled etc). There is a way to turn this off but it is not recommmended... Chris


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